From 6a4ad5df255114a39d664b4146eb908357de66d9 Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Fri, 1 Sep 2017 21:08:19 -0500 Subject: [PATCH 1/9] Update project name in CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2905e23..7bc5788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8 ) -project( ACIS_Py3Module CXX ) +project( ACISPython3 CXX ) # # Application Configuration From bbdc387ed833433d2eb5589503f09858af770d02 Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Fri, 1 Sep 2017 21:08:46 -0500 Subject: [PATCH 2/9] Add a custom target for install to ease up working with CLion --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bc5788..6510ba1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -601,3 +601,11 @@ set_property( APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "__init__.py" ) + +# +# Create a custom install target for calling inside Jetbrains CLion +# +add_custom_target( install_${PROJECT_NAME} + $(CMAKE_COMMAND) --build . --target install + COMMENT "Installing ${PROJECT_NAME}..." + ) From f551018324d52706f1781fcb2b6fd1c093a1bd3a Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Sat, 9 Dec 2017 23:26:42 -0600 Subject: [PATCH 3/9] Major reorganization --- CMakeLists.txt | 367 +--- CONTRIBUTING.md | 4 +- examples/01_generate_solid_block.py | 18 +- examples/02_boolean_subtract.py | 24 +- examples/03_sweeping.py | 34 +- examples/04_face_counting.py | 18 +- src/acis_api.cpp | 1445 ++++++++++++++ src/acis_api.h | 65 + src/acis_booleans.cpp | 333 ---- src/acis_booleans.h | 36 - src/acis_classes.cpp | 1694 ++++++++++++++++ src/acis_classes.h | 841 ++++++++ src/acis_entity.cpp | 2028 ++++++------------- src/acis_entity.h | 1167 +++++++++-- src/acis_enums.cpp | 22 + src/acis_enums.h | 102 + src/acis_geometric_atoms.cpp | 2778 --------------------------- src/acis_geometric_atoms.h | 114 -- src/acis_includes.h | 36 + src/acis_licensing.cpp | 61 - src/acis_lists.cpp | 440 ----- src/acis_lists.h | 46 - src/acis_modeler.cpp | 850 +++----- src/acis_modeler.h | 17 +- src/acis_operators.cpp | 802 ++++++++ src/acis_operators.h | 50 + src/acis_query.cpp | 181 -- src/acis_saverestore.cpp | 506 ----- src/acis_saverestore.h | 44 - src/acis_spa.cpp | 25 + src/{acis_query.h => acis_spa.h} | 21 +- src/acis_sweeping.cpp | 551 ------ src/acis_sweeping.h | 69 - src/utilities.h | 17 +- 34 files changed, 7011 insertions(+), 7795 deletions(-) create mode 100644 src/acis_api.cpp create mode 100644 src/acis_api.h delete mode 100644 src/acis_booleans.cpp delete mode 100644 src/acis_booleans.h create mode 100644 src/acis_classes.cpp create mode 100644 src/acis_classes.h create mode 100644 src/acis_enums.cpp create mode 100644 src/acis_enums.h delete mode 100644 src/acis_geometric_atoms.cpp delete mode 100644 src/acis_geometric_atoms.h create mode 100644 src/acis_includes.h delete mode 100644 src/acis_licensing.cpp delete mode 100644 src/acis_lists.cpp delete mode 100644 src/acis_lists.h create mode 100644 src/acis_operators.cpp create mode 100644 src/acis_operators.h delete mode 100644 src/acis_query.cpp delete mode 100644 src/acis_saverestore.cpp delete mode 100644 src/acis_saverestore.h create mode 100644 src/acis_spa.cpp rename src/{acis_query.h => acis_spa.h} (53%) delete mode 100644 src/acis_sweeping.cpp delete mode 100644 src/acis_sweeping.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6510ba1..969c389 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8 ) -project( ACISPython3 CXX ) +project( ACIS-Python3 CXX ) # # Application Configuration @@ -109,360 +109,27 @@ else() message( FATAL_ERROR "A valid Python interpreter is required for finding Python's site-packages directory!" ) endif() - -# -# ACIS Python Module - Licensing -# - -# Set source files -set( ACIS_SOURCES_Licensing - src/acis_licensing.cpp - ) - -# Generate Python module -add_library( Licensing SHARED ${ACIS_SOURCES_Licensing} ) - -# Set link targets -target_link_libraries( Licensing ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) - -# Add the build location to the include directories -target_include_directories( Licensing PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Licensing PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Licensing PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Licensing PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Licensing PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Licensing PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Entity (ENTITY, BODY, FACE, etc.) -# - -# Set source files -set( ACIS_SOURCES_Entity - src/acis_entity.h - src/acis_entity.cpp - ${PROJECT_BINARY_DIR}/acis_entity_export.h - ) - -# Generate Python module -add_library( Entity SHARED ${ACIS_SOURCES_Entity} ) - -# Generate export header file -generate_export_header( Entity - BASE_NAME acis_entity - ) - -# Set link targets -target_link_libraries( Entity ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} GeometricAtoms ) - -# Add the build location to the include directories -target_include_directories( Entity PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Entity PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Entity PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Entity PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Entity PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Entity PROPERTIES PREFIX "" ) - - # -# ACIS Python Module - Geometric Atoms (SPAposition, SPApar_pos, etc.) -# - -# Set source files -set( ACIS_SOURCES_GeometricAtoms - src/acis_geometric_atoms.h - src/acis_geometric_atoms.cpp - ${PROJECT_BINARY_DIR}/acis_geometric_atoms_export.h - ) - -# Generate Python module -add_library( GeometricAtoms SHARED ${ACIS_SOURCES_GeometricAtoms} ) - -# Generate export header file -generate_export_header( GeometricAtoms - BASE_NAME acis_geometric_atoms - ) - -# Set link targets -target_link_libraries( GeometricAtoms ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) - -# Add the build location to the include directories -target_include_directories( GeometricAtoms PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET GeometricAtoms PROPERTY CXX_STANDARD 11 ) -set_property( TARGET GeometricAtoms PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( GeometricAtoms PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( GeometricAtoms PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( GeometricAtoms PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Save & Restore (FileInfo, etc.) -# - -# Set source files -set( ACIS_SOURCES_SaveRestore - src/acis_saverestore.h - src/acis_saverestore.cpp - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_saverestore_export.h - ) - -# Generate Python module -add_library( SaveRestore SHARED ${ACIS_SOURCES_SaveRestore} ) - -# Generate export header file -generate_export_header( SaveRestore - BASE_NAME acis_saverestore - ) - -# Set link targets -target_link_libraries( SaveRestore ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Lists ) - -# Add the build location to the include directories -target_include_directories( SaveRestore PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET SaveRestore PROPERTY CXX_STANDARD 11 ) -set_property( TARGET SaveRestore PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( SaveRestore PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( SaveRestore PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( SaveRestore PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Lists (ENTITY_LIST, etc.) -# - -# Set source files -set( ACIS_SOURCES_Lists - src/acis_lists.h - src/acis_lists.cpp - ${PROJECT_BINARY_DIR}/acis_lists_export.h - ) - -# Generate Python module -add_library( Lists SHARED ${ACIS_SOURCES_Lists} ) - -# Generate export header file -generate_export_header( Lists - BASE_NAME acis_lists - ) - -# Set link targets -target_link_libraries( Lists ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity ) - -# Add the build location to the include directories -target_include_directories( Lists PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Lists PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Lists PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Lists PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Lists PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Lists PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Sweeping API -# - -# Set source files -set( ACIS_SOURCES_Sweeping - src/acis_sweeping.cpp - src/acis_sweeping.h - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_sweeping_export.h - ) - -# Generate Python module -add_library( Sweeping SHARED ${ACIS_SOURCES_Sweeping} ) - -# Generate export header file -generate_export_header( Sweeping - BASE_NAME acis_sweeping - ) - -# Set link targets. Note that Modeler has dependencies towards most helper modules. -target_link_libraries( Sweeping ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity GeometricAtoms ) - -# Add the build location to the include directories -target_include_directories( Sweeping PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Sweeping PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Sweeping PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Sweeping PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Sweeping PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Sweeping PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Booleans API -# - -# Set source files -set( ACIS_SOURCES_Booleans - src/acis_booleans.h - src/acis_booleans.cpp - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_booleans_export.h - ) - -# Generate Python module -add_library( Booleans SHARED ${ACIS_SOURCES_Booleans} ) - -# Generate export header file -generate_export_header( Booleans - BASE_NAME acis_booleans - ) - -# Set link targets -target_link_libraries( Booleans ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity ) - -# Add the build location to the include directories -target_include_directories( Booleans PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Booleans PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Booleans PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Booleans PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Booleans PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Booleans PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Query API -# - -# Set source files -set( ACIS_SOURCES_Query - src/acis_query.cpp - src/acis_query.h - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_query_export.h - ) - -# Generate Python module -add_library( Query SHARED ${ACIS_SOURCES_Query} ) - -# Generate export header file -generate_export_header( Query - BASE_NAME acis_query - ) - -# Set link targets. Note that Modeler has dependencies towards most helper modules. -target_link_libraries( Query ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity GeometricAtoms Lists ) - -# Add the build location to the include directories -target_include_directories( Query PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Query PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Query PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Query PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Query PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Query PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Modeler Core +# ACIS Python Module # # Set source files set( ACIS_SOURCES_Modeler + src/acis_includes.h src/acis_modeler.cpp src/acis_modeler.h + src/acis_api.cpp + src/acis_api.h + src/acis_classes.cpp + src/acis_classes.h + src/acis_entity.cpp + src/acis_entity.h + src/acis_enums.cpp + src/acis_enums.h + src/acis_operators.cpp + src/acis_operators.h + src/acis_spa.cpp + src/acis_spa.h src/utilities.cpp src/utilities.h ) @@ -471,7 +138,7 @@ set( ACIS_SOURCES_Modeler add_library( Modeler SHARED ${ACIS_SOURCES_Modeler} ) # Set link targets. Note that Modeler has dependencies towards most helper modules. -target_link_libraries( Modeler ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity Lists SaveRestore GeometricAtoms ) +target_link_libraries( Modeler ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) # Add the build location to the include directories target_include_directories( Modeler PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) @@ -500,7 +167,7 @@ set_target_properties( Modeler PROPERTIES PREFIX "" ) # Install Python modules to APP_INSTALL_DIR install( - TARGETS Modeler Licensing Entity Lists SaveRestore GeometricAtoms Sweeping Query Booleans + TARGETS Modeler DESTINATION ${APP_INSTALL_DIR}/${APP_MODULE_NAME} ) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b94548..cd23451 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,8 +28,8 @@ I would like to introduce some rules on contributing to this module. #### Naming conventions in the Python module * Python objects are defined as `ACIS_{ModuleName}_{ACISName}` and located in the header files -* Type functions are defined as `ACIS_{ModuleName}_{function_name}_{ACISName}`, e.g. _ACIS_GeometricAtoms_init_SPAposition_ -* Methods for types are defined as `ACIS_{ModuleName}_method_{ACISName}_{MethodName}`, e.g. _ACIS_Lists_method_ENTITY_LIST_add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side +* Type functions are defined as `ACIS_{ModuleName}_{function_name}_{ACISName}`, e.g. _a3dp_init_SPAposition_ +* Methods for types are defined as `ACIS_{ModuleName}_method_{ACISName}_{MethodName}`, e.g. _a3dp_method_ENTITY_LIST_add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side * Module variables are defined as `ACIS_{ModuleName}_{function_name}`, e.g. _ACIS_Topology_module_ * Module init functions are defined as `PyInit_{ModuleName}` * ACIS API calls are defined as `ACIS_{API Call}`, e.g. _ACIS_api_start_modeller_ which corresponds to _api_start_modeller()_ on the C++ side diff --git a/examples/01_generate_solid_block.py b/examples/01_generate_solid_block.py index a4d2b3f..f8ab8b7 100644 --- a/examples/01_generate_solid_block.py +++ b/examples/01_generate_solid_block.py @@ -8,19 +8,19 @@ """ from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Generate a simple solid block -pt1 = GeometricAtoms.SPAposition(0.0, 0.0, 0.0) -pt2 = GeometricAtoms.SPAposition(50.0, 50.0, 25.0) -block = Entity.BODY() +pt1 = Modeler.SPAposition(0.0, 0.0, 0.0) +pt2 = Modeler.SPAposition(50.0, 50.0, 25.0) +block = Modeler.BODY() Modeler.api_solid_block(pt1, pt2, block) @@ -29,24 +29,24 @@ block.id = 1 # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() save_list.add(block) # Set file name filename = "ACIS_Ex01.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/02_boolean_subtract.py b/examples/02_boolean_subtract.py index c1fa636..fec05bc 100644 --- a/examples/02_boolean_subtract.py +++ b/examples/02_boolean_subtract.py @@ -10,31 +10,31 @@ # This example is taken from the book "Rapid Prototyping and Engineering Applications" by Frank W. Liou (Example 5.1) from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Booleans +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Make a cuboid -block = Entity.BODY() +block = Modeler.BODY() Modeler.api_make_cuboid(150, 75, 25, block) # Generate and apply transformation to the cuboid -block_vector = GeometricAtoms.SPAvector(0.0, 0.0, 12.7) -block_transf = GeometricAtoms.translate_transf(block_vector) +block_vector = Modeler.SPAvector(0.0, 0.0, 12.7) +block_transf = Modeler.translate_transf(block_vector) Modeler.api_apply_transf(block, block_transf) # Make a frustum -cylinder = Entity.BODY() +cylinder = Modeler.BODY() Modeler.api_make_frustum(19.05, 12.7, 12.7, 12.7, cylinder) # Generate and apply transformation to the frustum -cylinder_vector = GeometricAtoms.SPAvector(0.0, 0.0, 6.35) -cylinder_transf = GeometricAtoms.translate_transf(cylinder_vector) +cylinder_vector = Modeler.SPAvector(0.0, 0.0, 6.35) +cylinder_transf = Modeler.translate_transf(cylinder_vector) Modeler.api_apply_transf(cylinder, cylinder_transf) # Subtract frustum from cuboid @@ -45,24 +45,24 @@ block.id = 1 # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() save_list.add(block) # Set file name filename = "ACIS_Ex02.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/03_sweeping.py b/examples/03_sweeping.py index 3664f14..c90b04e 100644 --- a/examples/03_sweeping.py +++ b/examples/03_sweeping.py @@ -8,47 +8,47 @@ """ from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Sweeping, Query +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Make a cuboid -block = Entity.BODY() +block = Modeler.BODY() Modeler.api_make_cuboid(150, 75, 25, block) # Get faces of the cuboid -face_list = Lists.ENTITY_LIST() -Query.api_get_faces(block, face_list) +face_list = Modeler.ENTITY_LIST() +Modeler.api_get_faces(block, face_list) # Choose any face from the cuboid's face list block_face = face_list.first() # Convert the chosen face into a sheet body -sheet_body = Entity.BODY() +sheet_body = Modeler.BODY() Modeler.api_sheet_from_ff([block_face], sheet_body) # Make a sweep path -pt1 = GeometricAtoms.SPAposition(0.0, 0.0, 0.0) -pt2 = GeometricAtoms.SPAposition(10.0, 55.0, 23.0) -sweep_path = Entity.EDGE() -Sweeping.api_make_sweep_path([pt1, pt2], sweep_path) +pt1 = Modeler.SPAposition(0.0, 0.0, 0.0) +pt2 = Modeler.SPAposition(10.0, 55.0, 23.0) +sweep_path = Modeler.EDGE() +Modeler.api_make_sweep_path([pt1, pt2], sweep_path) # Sweep the chosen face using the sweep path -opts = Sweeping.sweep_options() -swept_body = Entity.BODY() -Sweeping.api_sweep_with_options(sheet_body, sweep_path, opts, swept_body) +opts = Modeler.sweep_options() +swept_body = Modeler.BODY() +Modeler.api_sweep_with_options(sheet_body, sweep_path, opts, swept_body) # Assign attributes after generation sheet_body.name = "Swept FACE" sheet_body.id = 1 # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() # api_sweep_with_options will modify sheet_body object as defined in its documentation save_list.add(sheet_body) @@ -56,14 +56,14 @@ filename = "ACIS_Ex03.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/04_face_counting.py b/examples/04_face_counting.py index 8f4dec6..2a8cbec 100644 --- a/examples/04_face_counting.py +++ b/examples/04_face_counting.py @@ -8,17 +8,17 @@ """ from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Query +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Generate a truncated cone -frustum = Entity.BODY() +frustum = Modeler.BODY() Modeler.api_make_frustum(50, 20, 30, 10, frustum) # Assign attributes after generation @@ -26,32 +26,32 @@ frustum.id = 1 # Loop through the face list and print out the name of the entity type -face_list = Lists.ENTITY_LIST() -Query.api_get_faces(frustum, face_list) +face_list = Modeler.ENTITY_LIST() +Modeler.api_get_faces(frustum, face_list) for f in face_list.array(): fs = f.geometry() print(fs.type_name()) # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() save_list.add(frustum) # Set file name filename = "ACIS_Ex04.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/src/acis_api.cpp b/src/acis_api.cpp new file mode 100644 index 0000000..44442ce --- /dev/null +++ b/src/acis_api.cpp @@ -0,0 +1,1445 @@ +#include "acis_api.h" + + +bool disabled_acis_freelisting = false; + +PyObject * +a3dp_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_n = 0; + int input_freelisting = 1; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "n", + (char *) "freelisting", + NULL + }; + + // Try to parse input arguments and/or keywords + // api_start_modeller does not utilize the "n" argument, but following the implementation but make it optional + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist, &input_n, &input_freelisting)) + return NULL; + + // Disable ACIS freelisting facility if freelisting=False + if (!input_freelisting) + { + // Display a warning message + PyErr_WarnEx(PyExc_Warning, "Disabling ACIS freelisting...", 0); + // Disable ACIS freelisting + base_configuration base_config; + base_config.enable_freelists = FALSE; + base_config.raw_allocator = malloc; + base_config.raw_destructor = free; + initialize_base(&base_config); + // Set the global variable for terminate_nase + disabled_acis_freelisting = true; + } + + // Call ACIS API and check outcome + outcome result; + result = api_start_modeller(input_n); + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_stop_modeller(PyObject *self) +{ + // Call ACIS API and check outcome + outcome result; + result = api_stop_modeller(); + + // If ACIS freelisting disabled, we need to call terminate_base() + if (disabled_acis_freelisting) + { + // Display a warning message + PyErr_WarnEx(PyExc_Warning, "Terminating ACIS...", 0); + terminate_base(); + } + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_is_modeler_started(PyObject *self) +{ + // Initialize variables + logical check_modeler; + + // Call ACIS API + check_modeler = is_modeler_started(); + + // Return Python value + if (check_modeler) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + double input_value; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sd", kwlist, &input_name, &input_value)) + return NULL; + + API_BEGIN + + result = api_set_dbl_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + int input_value; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si", kwlist, &input_name, &input_value)) + return NULL; + + API_BEGIN + + result = api_set_int_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + const char *input_value = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &input_name, &input_value)) + return NULL; + + API_BEGIN + + result = api_set_str_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL, *input_block = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + (char *) "block", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_pt1, &input_pt2, &input_block)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_SPAposition(input_pt1)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_BODY(input_block)) + { + PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + SPAposition *_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; + SPAposition *_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; + BODY *&_block = (BODY *&) ((a3dp_BODY *) input_block)->base_obj._acis_obj; + + // Call ACIS API + result = api_solid_block(*_pt1, *_pt2, _block); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_x, input_y, input_z; + PyObject *input_body = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + (char *) "body", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddO", kwlist, &input_x, &input_y, &input_z, &input_body)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_body)) + { + PyErr_SetString(PyExc_TypeError, "The fourth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_body = (BODY *&) ((a3dp_BODY *) input_body)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_cuboid(input_x, input_y, input_z, _body); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2, input_top; + PyObject *input_frust = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "top", + (char *) "frust", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_frust)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_frust)) + { + PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_frust = (BODY *&) ((a3dp_BODY *) input_frust)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_frustum(input_height, input_radius1, input_radius2, input_top, _frust); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2; + int input_nsides; + PyObject *input_prism = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "nsides", + (char *) "frust", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_nsides, &input_prism)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_prism)) + { + PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_prism = (BODY *&) ((a3dp_BODY *) input_prism)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_prism(input_height, input_radius1, input_radius2, input_nsides, _prism); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2, input_top; + int input_nsides; + PyObject *input_pyramid = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "top", + (char *) "nsides", + (char *) "pyramid", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_nsides, &input_pyramid)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_pyramid)) + { + PyErr_SetString(PyExc_TypeError, "The sixth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_pyramid = (BODY *&) ((a3dp_BODY *) input_pyramid)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_pyramid(input_height, input_radius1, input_radius2, input_top, input_nsides, _pyramid); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_radius; + PyObject *input_sph = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "radius", + (char *) "sph", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_radius, &input_sph)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_sph)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_sph = (BODY *&) ((a3dp_BODY *) input_sph)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_sphere(input_radius, _sph); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_major_r, input_minor_r; + PyObject *input_tor = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "major_radius", + (char *) "minor_radius", + (char *) "tor", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_major_r, &input_minor_r, &input_tor)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tor)) + { + PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tor = (BODY *&) ((a3dp_BODY *) input_tor)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_torus(input_major_r, input_minor_r, _tor); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_entity = NULL, *input_trans = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "entity", + (char *) "trans", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity, &input_trans)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_entity)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + return NULL; + } + + if (!_PyCheck_SPAtransf(input_trans)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAtransf object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + ENTITY *&_entity = ((a3dp_BODY *) input_entity)->base_obj._acis_obj; + SPAtransf *&_trans = ((a3dp_SPAtransf *) input_trans)->_acis_obj; + + // Call ACIS API + result = api_apply_transf(_entity, *_trans); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_entity = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "entity", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_entity)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + ENTITY *&_entity = ((a3dp_BODY *) input_entity)->base_obj._acis_obj; + + // Call ACIS API + result = api_remove_transf(_entity); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_faces = NULL, *input_body = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "faces", + (char *) "body", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_faces, &input_body)) + return NULL; + + // First argument must be a tuple of faces + PyObject *seq = PySequence_Fast(input_faces, "First argument must be a sequence of FACE objects"); + + // ACIS API has a limitation in api_sheet_from_ff function: As of version R2017, it can handle only 1 face + Py_ssize_t face_array_size = PySequence_Fast_GET_SIZE(seq); + if (face_array_size <= 0) + { + PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); + Py_DECREF(seq); + return NULL; + } + else if (face_array_size > 1) + { + PyErr_WarnEx(PyExc_Warning, "ACIS API does not support generation of sheet bodies from multiple faces.", 0); + } + + PyObject *faceobj = PySequence_Fast_GET_ITEM(seq, 0); + + API_BEGIN + + FACE *&_face = (FACE *&) ((a3dp_FACE *) faceobj)->base_obj._acis_obj; + + FACE *_faces[1]; + _faces[0] = _face; + + BODY *&_body = (BODY *&) ((a3dp_BODY *) input_body)->base_obj._acis_obj; + + result = api_sheet_from_ff(1, _faces, _body); + + API_END + + // PySequence_Fast generates a new reference + Py_DECREF(seq); + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +/** + * Booleans API Interface Functions + */ + +PyObject * +a3dp_api_unite(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_unite(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_intersect(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_subtract(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_imprint(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs) +{ + /* TO-DO: Implement api_boolean_chop_body */ + return NULL; +} + +PyObject * +a3dp_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs) +{ + // According to the documentation, Python 3 doesn't do good with FILE* objects, so we take "file name" as an input + const char *input_filename = NULL; + int input_savemode; + PyObject *input_entitylist = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "file_name", + (char *) "text_mode", + (char *) "entity_list_save", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO", kwlist, &input_filename, &input_savemode, &input_entitylist)) + return NULL; + + // Check if the input is an ENTITY_LIST + if (!_PyCheck_ENTITY_LIST(input_entitylist)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + // Using the file name input as a string, create a file handle + FILE *_file_handle = fopen(input_filename, "w"); + + // Check if the file has been opened correctly + if (_file_handle == NULL) + { + PyErr_SetString(PyExc_IOError, "Cannot open file for writing!"); + return NULL; + } + + // Set file writing mode + logical _text_mode = (input_savemode == 0) ? FALSE : TRUE; + + API_NOP_BEGIN + + // Convert PyObject to ENTITY_LIST + ENTITY_LIST *_save_list = ((a3dp_ENTITY_LIST *) input_entitylist)->_acis_obj; + + + // Call ACIS API and check outcome + result = api_save_entity_list(_file_handle, _text_mode, *_save_list); + + API_NOP_END + + // Don't forget to close the file handle + fclose(_file_handle); + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_product_id = 0; + int input_units = 0; + PyObject *input_info = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "info", + (char *) "product_id", + (char *) "units", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii", kwlist, &input_info, &input_product_id, &input_units)) + return NULL; + + // Check if we have a FileInfo object + if (!_PyCheck_FileInfo(input_info)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + // Set up the value of mask + bool _product_id = input_product_id != 0; + bool _units = input_units != 0; + + unsigned long _mask; + if (_product_id && !_units) + { + _mask = FileIdent; + } + else if (!_product_id && _units) + { + _mask = FileUnits; + } + else + { + _mask = FileUnits | FileIdent; + } + + API_BEGIN + + // Convert PyObject to FileInfo + FileInfo *_info = ((a3dp_FileInfo *) input_info)->_acis_obj; + + result = api_set_file_info(_mask, *_info); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_info = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "info", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_info)) + return NULL; + + // Check if we have a FileInfo object + if (_PyCheck_FileInfo(input_info)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to FileInfo + FileInfo *_info = ((a3dp_FileInfo *) input_info)->_acis_obj; + + result = api_get_file_info(*_info); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_major_version, input_minor_version; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "major_version", + (char *) "minor_version", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_major_version, &input_minor_version)) + return NULL; + + API_BEGIN + + result = api_save_version(input_major_version, input_minor_version); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +/** + * Sweeping API Interface Functions + */ + +PyObject * +a3dp_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pts = NULL, *input_path = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pts", + (char *) "path", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pts, &input_path)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_EDGE(input_path)) + { + PyErr_SetString(PyExc_TypeError, "Second argument (path) must be an EDGE object"); + return NULL; + } + + // The first object must be a python sequence containing SPAposition objects + PyObject *seq = PySequence_Fast(input_pts, "First argument (pts) must be a sequence of SPAposition objects, such as a list or a tuple"); + + Py_ssize_t position_vector_size = PySequence_Fast_GET_SIZE(seq); + if (position_vector_size <= 0) + { + PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); + Py_DECREF(seq); + return NULL; + } + + // It seems unnecessary to implement a SPAposition container as python itself provides a handful of containers for every purpose + SPAposition_vector _pts; + + for (Py_ssize_t i = 0; i < position_vector_size; i++) + { + PyObject *pt_temp; + pt_temp = PySequence_Fast_GET_ITEM(seq, i); + if (!_PyCheck_SPAposition(pt_temp)) + { + PyErr_SetString(PyExc_TypeError, "Sequence must contain SPAposition objects"); + Py_DECREF(seq); + return NULL; + } + _pts.push_back(*((a3dp_SPAposition *) pt_temp)->_acis_obj); + } + + API_BEGIN + + EDGE *&_path = (EDGE *&) ((a3dp_EDGE *) input_path)->base_obj._acis_obj; + + // Don't use make_sweep_path_options for now + result = api_make_sweep_path(_pts, _path); + + API_END + + // PySequence_Fast returns a new reference + Py_DECREF(seq); + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Clear SPAposition container + _pts.clear(); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "arg1", + (char *) "arg2", + (char *) "arg3", + (char *) "arg4", + (char *) "arg5", + NULL + }; + + // Try to parse input arguments and/or keywords (hold sweep_options for now) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO|O", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5)) + return NULL; + + /* + * IMPORTANT NOTE: This function wraps all 4 api_sweep_with_options overloads in one single Python function. + * The reason is that Python doesn't allow overloading with same function names but different signatures. + */ + + // In all overloads, first argument is always an ENTITY object + if (!_PyCheck_ENTITY(input_arg1)) + { + PyErr_SetString(PyExc_TypeError, "First argument must be an ENTITY object"); + return NULL; + } + + API_BEGIN + + ENTITY *&_ent = (ENTITY *&) ((a3dp_ENTITY *) input_arg1)->_acis_obj; + + // Check if we are using the sweep along the axis overload + if (input_arg5 != NULL) + { + if (!_PyCheck_SPAposition(input_arg2)) + { + PyErr_SetString(PyExc_TypeError, "Second argument must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_SPAvector(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Third argument must be a SPAvector object"); + return NULL; + } + + if (!_PyCheck_sweep_options(input_arg4)) + { + PyErr_SetString(PyExc_TypeError, "Fourth argument must be a sweep_options object"); + return NULL; + } + + if (!_PyCheck_BODY(input_arg5)) + { + PyErr_SetString(PyExc_TypeError, "Fifth argument must be a BODY object"); + return NULL; + } + + SPAposition *&_root = (SPAposition *&) ((a3dp_SPAposition *) input_arg2)->_acis_obj; + SPAvector *&_axis = (SPAvector *&) ((a3dp_SPAvector *) input_arg3)->_acis_obj; + sweep_options *&_opts = (sweep_options *&) ((a3dp_sweep_options *) input_arg4)->_acis_obj; + BODY *&_new_body = (BODY *&) ((a3dp_BODY *) input_arg5)->base_obj._acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, *_root, *_axis, _opts, _new_body); + + } + else + { + // We must be using the other overloads, then the 3rd argument must be a sweep_options object + if (!_PyCheck_sweep_options(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Third argument must be a sweep_options object"); + return NULL; + } + + sweep_options *&_opts = (sweep_options *&) ((a3dp_sweep_options *) input_arg3)->_acis_obj; + + // and the 4th argument must be a BODY object + if (!_PyCheck_BODY(input_arg4)) + { + PyErr_SetString(PyExc_TypeError, "Fourth argument must be a BODY object"); + return NULL; + } + + BODY *&_new_body = (BODY *&) ((a3dp_BODY *) input_arg4)->base_obj._acis_obj; + + // Check for sweeping along a given edge or a wire overload + if (_PyCheck_ENTITY(input_arg2)) + { + ENTITY *&_path = (ENTITY *&) ((a3dp_ENTITY *) input_arg2)->_acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, _path, _opts, _new_body); + } + else if (PyFloat_Check(input_arg2)) + { + // We must be using sweeping along a specified distance overload + double _distance = PyFloat_AsDouble(input_arg2); + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, _distance, _opts, _new_body); + } + else if (_PyCheck_SPAvector(input_arg2)) + { + // We must be using sweeping along a specified vector overload + SPAvector *&_vec = (SPAvector *&) ((a3dp_SPAvector *) input_arg2)->_acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, *_vec, _opts, _new_body); + } + else + { + PyErr_SetString(PyExc_TypeError, "Second argument must be an ENTITY, float or SPAvector object"); + return NULL; + } + + } + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "entity", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_ent)) + return NULL; + + if (!_PyCheck_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + // Get the ACIS object from the user input + ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = get_owner_transf(_ent); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL, *input_ent_list = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ent", + (char *) "face_list", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) + return NULL; + + if (!_PyCheck_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + if (!_PyCheck_ENTITY_LIST(input_ent_list)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + API_BEGIN + + // Get the ACIS objects from the user input + ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; + ENTITY_LIST *&_face_list = ((a3dp_ENTITY_LIST *) input_ent_list)->_acis_obj; + + // Call ACIS function + result = api_get_faces(_ent, *_face_list); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } + +} + +PyObject * +a3dp_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL, *input_ent_list = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ent", + (char *) "edge_list", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) + return NULL; + + if (!_PyCheck_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + if (!_PyCheck_ENTITY_LIST(input_ent_list)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + API_BEGIN + + // Get the ACIS objects from the user input + ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; + ENTITY_LIST *&_edge_list = ((a3dp_ENTITY_LIST *) input_ent_list)->_acis_obj; + + // Call ACIS function + result = api_get_edges(_ent, *_edge_list); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } + +} diff --git a/src/acis_api.h b/src/acis_api.h new file mode 100644 index 0000000..0e7f970 --- /dev/null +++ b/src/acis_api.h @@ -0,0 +1,65 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_API_H +#define A3DPY_API_H + +#include +#include + +#include "acis_includes.h" +#include "acis_entity.h" +#include "acis_operators.h" +#include "acis_classes.h" +#include "acis_enums.h" +#include "acis_spa.h" +#include "utilities.h" + +#ifdef __cplusplus +extern "C" { +#endif + +PyObject *a3dp_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_stop_modeller(PyObject *self); +PyObject *a3dp_is_modeler_started(PyObject *self); +PyObject *a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_unite(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_API_H diff --git a/src/acis_booleans.cpp b/src/acis_booleans.cpp deleted file mode 100644 index 930c3d8..0000000 --- a/src/acis_booleans.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "acis_booleans.h" - - -/** - * NDBOOL_KEEP enum - */ - -static PyTypeObject - ACIS_Booleans_type_NDBOOL_KEEP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.NDBOOL_KEEP", /* tp_name */ - sizeof(ACIS_Booleans_NDBOOL_KEEP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ - }; - - -/** - * Booleans API Interface Functions - */ - -static PyObject * -ACIS_api_unite(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_unite(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_intersect(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_subtract(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_imprint(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs) -{ - /* TO-DO: Implement api_boolean_chop_body */ - return NULL; -} - -static PyMethodDef - module_methods[] = - { - { "api_unite", (PyCFunction) ACIS_api_unite, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean unite operation" }, - { "api_intersect", (PyCFunction) ACIS_api_intersect, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean intersect operation on two bodies" }, - { "api_subtract", (PyCFunction) ACIS_api_subtract, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean subtract operation" }, - { "api_imprint", (PyCFunction) ACIS_api_imprint, METH_VARARGS | METH_KEYWORDS, "Intersects two bodies and imprints the intersection graph on both bodies" }, - { "api_boolean_chop_body", (PyCFunction) ACIS_api_boolean_chop_body, METH_VARARGS | METH_KEYWORDS, "Executes simultaneous Boolean intersect and subtract operations on two bodies" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Booleans"; -const char *module_documentation = "Contains 3D ACIS Modeler booleans API related classes and functions"; - -static struct PyModuleDef - ACIS_Booleans_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Booleans(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Booleans_module); - if (m == NULL) - return NULL; - - // Create a dictionary object for NDBOOL_KEEP enum - PyObject *_ndbk_dict; - _ndbk_dict = PyDict_New(); - if (_ndbk_dict != NULL) - { - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_NEITHER", PyLong_FromLong(0L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_TOOL", PyLong_FromLong(1L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BLANK", PyLong_FromLong(2L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BOTH", PyLong_FromLong(3L)); - } - - // sweep_bool_type - ACIS_Booleans_type_NDBOOL_KEEP.tp_dict = _ndbk_dict; - if (PyType_Ready(&ACIS_Booleans_type_NDBOOL_KEEP) < 0) - return NULL; - Py_INCREF(&ACIS_Booleans_type_NDBOOL_KEEP); - PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &ACIS_Booleans_type_NDBOOL_KEEP); - - return m; -} - -PyObject *_ACIS_new_NDBOOL_KEEP() -{ - return PyObject_CallObject((PyObject *) &ACIS_Booleans_type_NDBOOL_KEEP, NULL); -} - -bool _ACIS_check_NDBOOL_KEEP(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Booleans_type_NDBOOL_KEEP; -} \ No newline at end of file diff --git a/src/acis_booleans.h b/src/acis_booleans.h deleted file mode 100644 index 85520ca..0000000 --- a/src/acis_booleans.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_BOOLEANS_H -#define ACIS_BOOLEANS_H - -#include -#include - -#include - -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "utilities.h" - -#include "acis_booleans_export.h" - -// Define NDBOOL_KEEP enum -typedef struct { - PyObject_HEAD -} ACIS_Booleans_NDBOOL_KEEP; - -PyObject ACIS_BOOLEANS_EXPORT *_ACIS_new_NDBOOL_KEEP(); - -bool ACIS_BOOLEANS_EXPORT _ACIS_check_NDBOOL_KEEP(PyObject *ob); - - -#endif // !ACIS_BOOLEANS_H diff --git a/src/acis_classes.cpp b/src/acis_classes.cpp new file mode 100644 index 0000000..049a475 --- /dev/null +++ b/src/acis_classes.cpp @@ -0,0 +1,1694 @@ +#include "acis_classes.h" + + + +/** + * SPAposition wrapper + */ + +void +a3dp_SPAposition_dealloc(a3dp_SPAposition *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAposition *self; + + self = (a3dp_SPAposition *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAposition(input_x, input_y, input_z); + + return 0; +} + +PyObject * +a3dp_SPAposition_repr(a3dp_SPAposition *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAposition object (%s, %s, %s)", _x, _y, _z); +} + +PyObject * +a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->coordinate(_i)); +} + +PyObject * +a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The coordinate input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_coordinate(_i, _new_c); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__x(a3dp_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +PyObject * +a3dp_SPAposition__y(a3dp_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +PyObject * +a3dp_SPAposition__z(a3dp_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +PyObject * +a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + return a3dp_SPAposition__x(self); +} + +PyObject * +a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + return a3dp_SPAposition__y(self); +} + +PyObject * +a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + return a3dp_SPAposition__z(self); +} + +int +a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + a3dp_SPAposition__set_x(self, value); + return 0; +} + +int +a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + a3dp_SPAposition__set_y(self, value); + return 0; +} + +int +a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + a3dp_SPAposition__set_z(self, value); + return 0; +} + +bool _PyCheck_SPAposition(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAposition; +} + +PyObject *_PyNew_SPAposition() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAposition, NULL); +} + +/** + * SPAvector class + */ + +void +a3dp_SPAvector_dealloc(a3dp_SPAvector *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAvector *self; + + self = (a3dp_SPAvector *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAvector(input_x, input_y, input_z); + + return 0; +} + +PyObject * +a3dp_SPAvector_repr(a3dp_SPAvector *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAvector object (%s, %s, %s)", _x, _y, _z); +} + +PyObject * +a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->component(_i)); +} + +PyObject * +a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_component(_i, _new_c); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__x(a3dp_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +PyObject * +a3dp_SPAvector__y(a3dp_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +PyObject * +a3dp_SPAvector__z(a3dp_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +PyObject * +a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + return a3dp_SPAvector__x(self); +} + +PyObject * +a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + return a3dp_SPAvector__y(self); +} + +PyObject * +a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + return a3dp_SPAvector__z(self); +} + +int +a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + a3dp_SPAvector__set_x(self, value); + return 0; +} + +int +a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + a3dp_SPAvector__set_y(self, value); + return 0; +} + +int +a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + a3dp_SPAvector__set_z(self, value); + return 0; +} + +bool _PyCheck_SPAvector(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAvector; +} + +PyObject *_PyNew_SPAvector() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAvector, NULL); +} + +/** + * SPAunit_vector wrapper + */ + +void +a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAunit_vector *self; + + self = (a3dp_SPAunit_vector *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAunit_vector(input_x, input_y, input_z); + + return 0; +} + +PyObject * +a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAunit_vector object (%s, %s, %s)", _x, _y, _z); +} + +PyObject * +a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->component(_i)); +} + +PyObject * +a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_component(_i, _new_c); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +PyObject * +a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +PyObject * +a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +PyObject * +a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + return a3dp_SPAunitvector__x(self); +} + +PyObject * +a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + return a3dp_SPAunitvector__y(self); +} + +PyObject * +a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + return a3dp_SPAunitvector__z(self); +} + +int +a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + a3dp_SPAunitvector__set_x(self, value); + return 0; +} + +int +a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + a3dp_SPAunitvector__set_y(self, value); + return 0; +} + +int +a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + a3dp_SPAunitvector__set_z(self, value); + return 0; +} + +bool _PyCheck_SPAunit_vector(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAunitvector; +} + +PyObject *_PyNew_SPAunit_vector() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAunitvector, NULL); +} + +/** + * SPAmatrix wrapper + */ + +void +a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAmatrix *self; + + self = (a3dp_SPAmatrix *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAmatrix(); + + return 0; +} + +PyObject * +a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg) +{ + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + // Create a new SPAvector python object + PyObject *_python_ret = _PyNew_SPAvector(); + + // Convert python input argument into a C variable + int _in_col = (int) PyLong_AsLong(arg); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->column(_in_col); + + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg) +{ + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + // Create a new SPAvector python object + PyObject *_python_ret = _PyNew_SPAvector(); + + // Convert python input argument into a C variable + int _in_row = (int) PyLong_AsLong(arg); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->row(_in_row); + + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self) +{ + // Create a new SPAmatrix python object + PyObject *_python_ret = _PyNew_SPAmatrix(); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->inverse(); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self) +{ + // Create a new SPAmatrix python object + PyObject *_python_ret = _PyNew_SPAmatrix(); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->transpose(); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self) +{ + // Execute the ACIS function and return the value as a python object + return PyFloat_FromDouble(self->_acis_obj->determinant()); +} + +PyObject * +a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + int input_row, input_col; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "row", + (char *) "col", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_row, &input_col)) + return NULL; + + // Execute the ACIS function and return the value as a python object + return PyFloat_FromDouble(self->_acis_obj->element(input_row, input_col)); +} + +PyObject * +a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + int input_row, input_col; + double input_new_e; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "row", + (char *) "col", + (char *) "new_e", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iid", kwlist, &input_row, &input_col, &input_new_e)) + return NULL; + + // Execute the ACIS function + self->_acis_obj->set_element(input_row, input_col, input_new_e); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self) +{ + logical _ret_val = self->_acis_obj->is_identity(); + + if (_ret_val) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +bool _PyCheck_SPAmatrix(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAmatrix; +} + +PyObject *_PyNew_SPAmatrix() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAmatrix, NULL); +} + +/** + * SPAtransf wrapper + */ + +void +a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAtransf *self; + + self = (a3dp_SPAtransf *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAtransf(); + + return 0; +} + +PyObject * +a3dp_SPAtransf__affine(a3dp_SPAtransf *self) +{ + PyObject *_ret = _PyNew_SPAmatrix(); + + *((a3dp_SPAmatrix *) _ret)->_acis_obj = self->_acis_obj->affine(); + + return _ret; +} + +PyObject * +a3dp_SPAtransf__inverse(a3dp_SPAtransf *self) +{ + PyObject *_ret = _PyNew_SPAtransf(); + + *((a3dp_SPAtransf *) _ret)->_acis_obj = self->_acis_obj->inverse(); + + return _ret; +} + +PyObject * +a3dp_SPAtransf__translation(a3dp_SPAtransf *self) +{ + PyObject *_ret = _PyNew_SPAvector(); + + *((a3dp_SPAvector *) _ret)->_acis_obj = self->_acis_obj->translation(); + + return _ret; +} + +PyObject * +a3dp_SPAtransf__identity(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->identity(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_SPAtransf__reflect(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->reflect(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_SPAtransf__rotate(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->rotate(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_SPAtransf__scaling(a3dp_SPAtransf *self) +{ + return PyFloat_FromDouble(self->_acis_obj->scaling()); +} + +PyObject * +a3dp_SPAtransf__shear(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->shear(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + + +bool _PyCheck_SPAtransf(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAtransf; +} + +PyObject *_PyNew_SPAtransf() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAtransf, NULL); +} + +/** + * SPApar_pos wrapper + */ + +void +a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPApar_pos *self; + + self = (a3dp_SPApar_pos *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPApar_pos(); + + return 0; +} + +PyObject * +a3dp_SPAparpos_repr(a3dp_SPApar_pos *self) +{ + double u = self->_acis_obj->u; double v = self->_acis_obj->v; + + char *_u = PyOS_double_to_string(u, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_u) + return PyErr_NoMemory(); + + char *_v = PyOS_double_to_string(v, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_v) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPApar_pos object (%s, %s)", _u, _v); +} + +PyObject * +a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->u); +} + +int +a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + self->_acis_obj->u = PyFloat_AsDouble(value); + return 0; +} + +PyObject * +a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->v); +} + +int +a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + self->_acis_obj->v = PyFloat_AsDouble(value); + return 0; +} + +bool _PyCheck_SPApar_pos(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAparpos; +} + +PyObject *_PyNew_SPApar_pos() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAparpos, NULL); +} + +/** + * SPApar_vec wrapper + */ + +void +a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPApar_vec *self; + + self = (a3dp_SPApar_vec *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPApar_vec(); + + return 0; +} + +PyObject * +a3dp_SPAparvec_repr(a3dp_SPApar_vec *self) +{ + double du = self->_acis_obj->du; double dv = self->_acis_obj->dv; + + char *_du = PyOS_double_to_string(du, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_du) + return PyErr_NoMemory(); + + char *_dv = PyOS_double_to_string(dv, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_dv) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPApar_vec object (%s, %s)", _du, _dv); +} + +PyObject * +a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->du); +} + +int +a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + self->_acis_obj->du = PyFloat_AsDouble(value); + return 0; +} + +PyObject * +a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->dv); +} + +int +a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + self->_acis_obj->dv = PyFloat_AsDouble(value); + return 0; +} + +bool _PyCheck_SPApar_vec(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAparvec; +} + +PyObject *_PyNew_SPApar_vec() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAparvec, NULL); +} + + +/** + * FileInfo class + */ + +void +a3dp_FileInfo_dealloc(a3dp_FileInfo *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object itself + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_FileInfo *self; + + self = (a3dp_FileInfo *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + self->_acis_obj = ACIS_NEW FileInfo(); + return 0; +} + +PyObject * +a3dp_FileInfo__acis_version(a3dp_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->acis_version()); +} + +PyObject * +a3dp_FileInfo__date(a3dp_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->date()); +} + +PyObject * +a3dp_FileInfo__file_version(a3dp_FileInfo *self) +{ + return PyLong_FromLong((long) self->_acis_obj->file_version()); +} + +PyObject * +a3dp_FileInfo__product_id(a3dp_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->product_id()); +} + +PyObject * +a3dp_FileInfo__reset(a3dp_FileInfo *self) +{ + self->_acis_obj->reset(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__reset_vars(a3dp_FileInfo *self) +{ + self->_acis_obj->reset_vars(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__restore(a3dp_FileInfo *self) +{ + self->_acis_obj->restore(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__save(a3dp_FileInfo *self) +{ + self->_acis_obj->save(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + unsigned long input_field; + PyObject *input_file = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "field", + (char *) "file", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "lO", kwlist, &input_field, &input_file)) + return NULL; + + // Check if the user input is a FileInfo object + if (_PyCheck_FileInfo(input_file)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + // Convert PyObject to ENTITY_LIST + FileInfo *_file = ((a3dp_FileInfo *) input_file)->_acis_obj; + + // Execute ACIS function + self->_acis_obj->set_masked(input_field, *_file); + + // Return None + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + const char *input_id = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "id", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &input_id)) + return NULL; + + self->_acis_obj->set_product_id(input_id); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + double input_count; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "count", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_count)) + return NULL; + + self->_acis_obj->set_units(input_count); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__tol_abs(a3dp_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->tol_abs()); +} + +PyObject * +a3dp_FileInfo__tol_nor(a3dp_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->tol_nor()); +} + +PyObject * +a3dp_FileInfo__units(a3dp_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->units()); +} + +PyObject * +a3dp_FileInfo__valid(a3dp_FileInfo *self) +{ + self->_acis_obj->valid(); + Py_RETURN_NONE; +} + +bool +_PyCheck_FileInfo(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_FileInfo; +} + +void +a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_make_sweep_path_options *self; + + self = (a3dp_make_sweep_path_options *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW make_sweep_path_options(); + + return 0; +} + +void +a3dp_sweepoptions_dealloc(a3dp_sweep_options *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_sweep_options *self; + + self = (a3dp_sweep_options *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW sweep_options(); + + return 0; +} + +PyObject * +a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) +{ + // Just a testing... + self->_acis_obj->set_bool_type(KEEP_BOTH); + + Py_RETURN_NONE; +} + + +PyObject * +_PyNew_make_sweep_path_options() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_make_sweep_path_options, NULL); +} + +bool +_PyCheck_make_sweep_path_options(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_make_sweep_path_options; +} + +PyObject * +_PyNew_sweep_options() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_sweep_options, NULL); +} + +bool +_PyCheck_sweep_options(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_sweep_options; +} diff --git a/src/acis_classes.h b/src/acis_classes.h new file mode 100644 index 0000000..fff4746 --- /dev/null +++ b/src/acis_classes.h @@ -0,0 +1,841 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_CLASSES_H +#define A3DPY_CLASSES_H + +#include +#include + +#include "acis_includes.h" +#include "utilities.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// Define SPAposition +typedef struct +{ + PyObject_HEAD + SPAposition *_acis_obj; +} a3dp_SPAposition; + +void a3dp_SPAposition_dealloc(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAposition_repr(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__x(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition__y(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition__z(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure); +PyObject *a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure); +PyObject *a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure); +int a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure); +int a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure); +int a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAposition[] = + { + { (char *) "x_value", (getter) a3dp_SPAposition_x_getter, (setter) a3dp_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, + { (char *) "y_value", (getter) a3dp_SPAposition_y_getter, (setter) a3dp_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, + { (char *) "z_value", (getter) a3dp_SPAposition_z_getter, (setter) a3dp_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAposition[] = + { + { "coordinate", (PyCFunction) a3dp_SPAposition__coordinate, METH_O, "Returns the i-th component value" }, + { "set_coordinate", (PyCFunction) a3dp_SPAposition__set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, + { "set_x", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the x-coordinate value" }, + { "set_y", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the y-coordinate value" }, + { "set_z", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the z-coordinate value" }, + { "x", (PyCFunction) a3dp_SPAposition__x, METH_NOARGS, "Returns the x-coordinate value" }, + { "y", (PyCFunction) a3dp_SPAposition__y, METH_NOARGS, "Returns the y-coordinate value" }, + { "z", (PyCFunction) a3dp_SPAposition__z, METH_NOARGS, "Returns the z-coordinate value" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAposition = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAposition", /* tp_name */ + sizeof(a3dp_SPAposition), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAposition_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAposition_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAposition_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAposition, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAposition, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAposition_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAposition_new, /* tp_new */ + }; + + +PyObject *_PyNew_SPAposition(); + +bool _PyCheck_SPAposition(PyObject *ob); + +// Define SPAvector +typedef struct +{ + PyObject_HEAD + SPAvector *_acis_obj; +} a3dp_SPAvector; + +void a3dp_SPAvector_dealloc(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAvector_repr(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__x(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector__y(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector__z(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure); +int a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure); +int a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure); +int a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAvector[] = + { + { (char *) "x_value", (getter) a3dp_SPAvector_x_getter, (setter) a3dp_SPAvector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) a3dp_SPAvector_y_getter, (setter) a3dp_SPAvector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) a3dp_SPAvector_z_getter, (setter) a3dp_SPAvector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAvector[] = + { + { "component", (PyCFunction) a3dp_SPAvector__component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) a3dp_SPAvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) a3dp_SPAvector__x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) a3dp_SPAvector__y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) a3dp_SPAvector__z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAvector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAvector", /* tp_name */ + sizeof(a3dp_SPAvector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAvector_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAvector_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAvector_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAvector, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAvector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAvector_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAvector_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAvector(); + +bool _PyCheck_SPAvector(PyObject *ob); + +// Define SPAunit_vector +typedef struct +{ + PyObject_HEAD + SPAunit_vector *_acis_obj; +} a3dp_SPAunit_vector; + +void a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +int a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +int a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +int a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAunit_vector[] = + { + { (char *) "x_value", (getter) a3dp_SPAunitvector_x_getter, (setter) a3dp_SPAunitvector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) a3dp_SPAunitvector_y_getter, (setter) a3dp_SPAunitvector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) a3dp_SPAunitvector_z_getter, (setter) a3dp_SPAunitvector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAunit_vector[] = + { + { "component", (PyCFunction) a3dp_SPAunitvector__component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) a3dp_SPAunitvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) a3dp_SPAunitvector__x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) a3dp_SPAunitvector__y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) a3dp_SPAunitvector__z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAunitvector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAunit_vector", /* tp_name */ + sizeof(a3dp_SPAunit_vector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAunitvector_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAunitvector_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAunitvector_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAunit_vector, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAunit_vector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAunitvector_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAunitvector_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAunit_vector(); + +bool _PyCheck_SPAunit_vector(PyObject *ob); + +// Define SPAmatrix +typedef struct +{ + PyObject_HEAD + SPAmatrix *_acis_obj; +} a3dp_SPAmatrix; + +void a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg); +PyObject *a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg); +PyObject *a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self); + +static PyMethodDef + a3dp_methods_SPAmatrix[] = + { + { "column", (PyCFunction) a3dp_SPAmatrix__column, METH_O, "Extracts a column from this matrix" }, + { "row", (PyCFunction) a3dp_SPAmatrix__row, METH_O, "Extracts a row from this matrix" }, + { "element", (PyCFunction) a3dp_SPAmatrix__element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, + { "set_element", (PyCFunction) a3dp_SPAmatrix__set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, + { "determinant", (PyCFunction) a3dp_SPAmatrix__determinant, METH_NOARGS, "Returns the determinant of this matrix" }, + { "transpose", (PyCFunction) a3dp_SPAmatrix__transpose, METH_NOARGS, "Returns a transpose of this matrix" }, + { "inverse", (PyCFunction) a3dp_SPAmatrix__inverse, METH_NOARGS, "Returns the inverse of this matrix" }, + { "is_identity", (PyCFunction) a3dp_SPAmatrix__is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAmatrix = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAmatrix", /* tp_name */ + sizeof(a3dp_SPAmatrix), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAmatrix_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAmatrix, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAmatrix_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAmatrix_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAmatrix(); + +bool _PyCheck_SPAmatrix(PyObject *ob); + +// Define SPAtransf +typedef struct +{ + PyObject_HEAD + SPAtransf *_acis_obj; +} a3dp_SPAtransf; + +void a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAtransf__affine(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__inverse(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__translation(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__identity(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__reflect(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__rotate(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__scaling(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__shear(a3dp_SPAtransf *self); + +static PyMethodDef + a3dp_methods_SPAtransf[] = + { + { "affine", (PyCFunction) a3dp_SPAtransf__affine, METH_NOARGS, "Returns the affine portion of the transformation" }, + { "inverse", (PyCFunction) a3dp_SPAtransf__inverse, METH_NOARGS, "Returns the inverse transformation" }, + { "translation", (PyCFunction) a3dp_SPAtransf__translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, + { "identity", (PyCFunction) a3dp_SPAtransf__identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, + { "reflect", (PyCFunction) a3dp_SPAtransf__reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, + { "rotate", (PyCFunction) a3dp_SPAtransf__rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, + { "scaling", (PyCFunction) a3dp_SPAtransf__scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, + { "shear", (PyCFunction) a3dp_SPAtransf__shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAtransf = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(a3dp_SPAtransf), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAtransf_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAtransf represents a general 3D affine transformation", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAtransf, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAtransf_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAtransf_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAtransf(); + +bool _PyCheck_SPAtransf(PyObject *ob); + +// Define SPApar_pos +typedef struct +{ + PyObject_HEAD + SPApar_pos *_acis_obj; +} a3dp_SPApar_pos; + +void a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self); +PyObject *a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAparpos_repr(a3dp_SPApar_pos *self); +PyObject *a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); +int a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); +PyObject *a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); +int a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAparpos[] = + { + { (char *) "u", (getter) a3dp_SPAparpos_u_getter, (setter) a3dp_SPAparpos_u_setter, (char *) "value of the u parameter", NULL }, + { (char *) "v", (getter) a3dp_SPAparpos_v_getter, (setter) a3dp_SPAparpos_v_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAparpos = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(a3dp_SPApar_pos), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAparpos_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAparpos_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAparpos_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAparpos, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAparpos_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAparpos_new, /* tp_new */ + }; + +PyObject *_PyNew_SPApar_pos(); + +bool _PyCheck_SPApar_pos(PyObject *ob); + +// Define SPApar_vec +typedef struct +{ + PyObject_HEAD + SPApar_vec *_acis_obj; +} a3dp_SPApar_vec; + +void a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self); +PyObject *a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAparvec_repr(a3dp_SPApar_vec *self); +PyObject *a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); +int a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); +PyObject *a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); +int a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAparvec[] = + { + { (char *) "du", (getter) a3dp_SPAparvec_du_getter, (setter) a3dp_SPAparvec_du_setter, (char *) "value of the u parameter", NULL }, + { (char *) "dv", (getter) a3dp_SPAparvec_dv_getter, (setter) a3dp_SPAparvec_dv_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAparvec = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPApar_vec", /* tp_name */ + sizeof(a3dp_SPApar_vec), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAparvec_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAparvec_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAparvec_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAparvec, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAparvec_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAparvec_new, /* tp_new */ + }; + +PyObject *_PyNew_SPApar_vec(); + +bool _PyCheck_SPApar_vec(PyObject *ob); + +// Define FileInfo +typedef struct +{ + PyObject_HEAD + FileInfo *_acis_obj; +} a3dp_FileInfo; + +void a3dp_FileInfo_dealloc(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__acis_version(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__date(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__file_version(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__product_id(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__reset(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__reset_vars(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__restore(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__save(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__tol_abs(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__tol_nor(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__units(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__valid(a3dp_FileInfo *self); + +static PyMemberDef + a3dp_members_FileInfo[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_FileInfo[] = + { + { "acis_version", (PyCFunction) a3dp_FileInfo__acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, + { "date", (PyCFunction) a3dp_FileInfo__date, METH_NOARGS, "Returns the date on the save file" }, + { "file_version", (PyCFunction) a3dp_FileInfo__file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, + { "product_id", (PyCFunction) a3dp_FileInfo__product_id, METH_NOARGS, "Returns the ID of the product" }, + { "reset", (PyCFunction) a3dp_FileInfo__reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, + { "reset_vars", (PyCFunction) a3dp_FileInfo__reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, + { "restore", (PyCFunction) a3dp_FileInfo__restore, METH_NOARGS, "Restores the file information from a save file" }, + { "save", (PyCFunction) a3dp_FileInfo__save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, + //{ "set_masked", (PyCFunction)a3dp_FileInfo__set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, + { "set_product_id", (PyCFunction) a3dp_FileInfo__set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, + { "set_units", (PyCFunction) a3dp_FileInfo__set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, + { "tol_abs", (PyCFunction) a3dp_FileInfo__tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, + { "tol_nor", (PyCFunction) a3dp_FileInfo__tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, + { "units", (PyCFunction) a3dp_FileInfo__units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, + { "valid", (PyCFunction) a3dp_FileInfo__valid, METH_NOARGS, "Checks the values of the units and product id" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_FileInfo = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FileInfo", /* tp_name */ + sizeof(a3dp_FileInfo), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_FileInfo_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "FileInfo object contains additional required save file header information", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_FileInfo, /* tp_methods */ + a3dp_members_FileInfo, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_FileInfo_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_FileInfo_new, /* tp_new */ + }; + +bool _PyCheck_FileInfo(PyObject *ob); + +// Define sweep_options +typedef struct +{ + PyObject_HEAD + sweep_options *_acis_obj; +} a3dp_sweep_options; + +void a3dp_sweepoptions_dealloc(a3dp_sweep_options *self); +PyObject *a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); + +static PyMethodDef + a3dp_methods_sweepoptions[] = + { + { "set_bool_type", (PyCFunction) a3dp_sweepoptions__set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_sweep_options = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_options", /* tp_name */ + sizeof(a3dp_sweep_options), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_sweepoptions_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_sweepoptions, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_sweepoptions_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_sweepoptions_new, /* tp_new */ + }; + +PyObject *_PyNew_sweep_options(); +bool _PyCheck_sweep_options(PyObject *ob); + +// Define make_sweep_path_options +typedef struct +{ + PyObject_HEAD + make_sweep_path_options *_acis_obj; +} a3dp_make_sweep_path_options; + +void a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self); +PyObject *a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs); + +static PyTypeObject + a3dp_type_make_sweep_path_options = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.make_sweep_path_options", /* tp_name */ + sizeof(a3dp_make_sweep_path_options), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_makesweeppathoptions_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_makesweeppathoptions_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_makesweeppathoptions_new, /* tp_new */ + }; + +PyObject *_PyNew_make_sweep_path_options(); +bool _PyCheck_make_sweep_path_options(PyObject *ob); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_CLASSES_H diff --git a/src/acis_entity.cpp b/src/acis_entity.cpp index 677e3cf..e9f61a5 100644 --- a/src/acis_entity.cpp +++ b/src/acis_entity.cpp @@ -2,11 +2,11 @@ /** - * 3D ACIS Modeler - ENTITY wrapper + * ENTITY class */ int -ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg) +a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg) { // Use Py_VISIT macro for PyObject-type variables Py_VISIT(self->attrib_name); @@ -16,7 +16,7 @@ ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg } int -ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_clear(a3dp_ENTITY *self) { // Set ACIS object to NULL to allow it automatically deleted by ACIS memory manager //self->_acis_obj = NULL; @@ -29,14 +29,14 @@ ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self) } void -ACIS_Entity_dealloc_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_dealloc(a3dp_ENTITY *self) { - ACIS_Entity_clear_ENTITY(self); + a3dp_ENTITY_clear(self); Py_TYPE(self)->tp_free((PyObject *) self); } PyObject * -ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs) +a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started if (!is_modeler_started()) @@ -45,9 +45,9 @@ ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs) return NULL; } - ACIS_Entity_ENTITY *self; + a3dp_ENTITY *self; - self = (ACIS_Entity_ENTITY *) type->tp_alloc(type, 0); + self = (a3dp_ENTITY *) type->tp_alloc(type, 0); if (self != NULL) { self->attrib_name = PyUnicode_FromString(""); @@ -72,13 +72,13 @@ ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs) } int -ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwargs) +a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs) { // PyObject *input_name = NULL; // PyObject *input_id = NULL; // PyObject *tmp; // -// static char *kwlist[] = +// char *kwlist[] = // { // (char *) "name", // (char *) "id", @@ -128,7 +128,7 @@ ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwar } PyObject * -ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_repr(a3dp_ENTITY *self) { const char *_name = PyUnicode_AsUTF8(self->attrib_name); int _id = (int) PyLong_AsLong(self->attrib_object_id); @@ -136,7 +136,7 @@ ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self) } PyObject * -ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_str(a3dp_ENTITY *self) { const char *acis_obj_status = NULL; if (self->_acis_obj == NULL) @@ -148,14 +148,14 @@ ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self) } PyObject * -ACIS_Entity_method_ENTITY_get_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_name); return self->attrib_name; } int -ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) { @@ -188,21 +188,21 @@ ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *va } PyObject * -ACIS_Entity_method_ENTITY_type_name(PyObject *self) +a3dp_ENTITY_type_name(PyObject *self) { - const char *_retval = ((ACIS_Entity_ENTITY *)self)->_acis_obj->type_name(); + const char *_retval = ((a3dp_ENTITY *)self)->_acis_obj->type_name(); return PyUnicode_FromString(_retval); } PyObject * -ACIS_Entity_method_ENTITY_get_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_object_id); return self->attrib_object_id; } int -ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) { @@ -239,29 +239,29 @@ ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject * /** - * 3D ACIS Modeler - BODY wrapper + * BODY class */ -static int -ACIS_Entity_init_BODY(ACIS_Entity_BODY *self, PyObject *args, PyObject *kwargs) +int +a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_BODY(ACIS_Entity_BODY *self) +PyObject * +a3dp_BODY_repr(a3dp_BODY *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("BODY object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_BODY(ACIS_Entity_BODY *self) +PyObject * +a3dp_BODY_str(a3dp_BODY *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -272,92 +272,31 @@ ACIS_Entity_str_BODY(ACIS_Entity_BODY *self) return PyUnicode_FromFormat("BODY object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_BODY[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_BODY[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_BODY[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_BODY = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.BODY", /* tp_name */ - sizeof(ACIS_Entity_BODY), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_BODY, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_BODY, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS BODY class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_BODY, /* tp_methods */ - ACIS_Entity_members_BODY, /* tp_members */ - ACIS_Entity_getseters_BODY, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_BODY, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - FACE wrapper + * FACE class */ -static int -ACIS_Entity_init_FACE(ACIS_Entity_FACE *self, PyObject *args, PyObject *kwargs) +int +a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_FACE(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE_repr(a3dp_FACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("FACE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_FACE(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE_str(a3dp_FACE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -368,8 +307,8 @@ ACIS_Entity_str_FACE(ACIS_Entity_FACE *self) return PyUnicode_FromFormat("FACE object (%s)", acis_obj_status); } -static PyObject * -ACIS_Entity_method_FACE_sense(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE__sense(a3dp_FACE *self) { logical _revbit; _revbit = ((FACE *) self->base_obj._acis_obj)->sense(); @@ -381,103 +320,40 @@ ACIS_Entity_method_FACE_sense(ACIS_Entity_FACE *self) Py_RETURN_FALSE; } -static PyObject * -ACIS_Entity_method_FACE_geometry(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE__geometry(a3dp_FACE *self) { - PyObject *_retobj = _ACIS_new_SURFACE(); + PyObject *_retobj = _PyNew_SURFACE(); // Store everything as ENTITY - ((ACIS_Entity_SURFACE *) _retobj)->base_obj._acis_obj = (ENTITY *) ((FACE *) self->base_obj._acis_obj)->geometry(); + ((a3dp_SURFACE *) _retobj)->base_obj._acis_obj = (ENTITY *) ((FACE *) self->base_obj._acis_obj)->geometry(); return _retobj; } -static PyGetSetDef - ACIS_Entity_getseters_FACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_FACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_FACE[] = - { - { "sense", (PyCFunction) ACIS_Entity_method_FACE_sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, - { "geometry", (PyCFunction) ACIS_Entity_method_FACE_geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_FACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FACE", /* tp_name */ - sizeof(ACIS_Entity_FACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_FACE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_FACE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS FACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_FACE, /* tp_methods */ - ACIS_Entity_members_FACE, /* tp_members */ - ACIS_Entity_getseters_FACE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_FACE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - EDGE wrapper + * EDGE class */ -static int -ACIS_Entity_init_EDGE(ACIS_Entity_EDGE *self, PyObject *args, PyObject *kwargs) +int +a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_EDGE(ACIS_Entity_EDGE *self) +PyObject * +a3dp_EDGE_repr(a3dp_EDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("EDGE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_EDGE(ACIS_Entity_EDGE *self) +PyObject * +a3dp_EDGE_str(a3dp_EDGE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -488,92 +364,31 @@ ACIS_Entity_str_EDGE(ACIS_Entity_EDGE *self) return PyUnicode_FromFormat("EDGE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_EDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_EDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_EDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_EDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.EDGE", /* tp_name */ - sizeof(ACIS_Entity_EDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_EDGE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_EDGE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS EDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_EDGE, /* tp_methods */ - ACIS_Entity_members_EDGE, /* tp_members */ - ACIS_Entity_getseters_EDGE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_EDGE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - WIRE wrapper + * WIRE class */ -static int -ACIS_Entity_init_WIRE(ACIS_Entity_WIRE *self, PyObject *args, PyObject *kwargs) +int +a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_WIRE(ACIS_Entity_WIRE *self) +PyObject * +a3dp_WIRE_repr(a3dp_WIRE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("WIRE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_WIRE(ACIS_Entity_WIRE *self) +PyObject * +a3dp_WIRE_str(a3dp_WIRE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -584,92 +399,30 @@ ACIS_Entity_str_WIRE(ACIS_Entity_WIRE *self) return PyUnicode_FromFormat("WIRE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_WIRE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_WIRE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_WIRE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_WIRE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.WIRE", /* tp_name */ - sizeof(ACIS_Entity_WIRE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_WIRE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_WIRE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS WIRE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_WIRE, /* tp_methods */ - ACIS_Entity_members_WIRE, /* tp_members */ - ACIS_Entity_getseters_WIRE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_WIRE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - LUMP wrapper + * LUMP class */ -static int -ACIS_Entity_init_LUMP(ACIS_Entity_LUMP *self, PyObject *args, PyObject *kwargs) +int +a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_LUMP(ACIS_Entity_LUMP *self) +PyObject * +a3dp_LUMP_repr(a3dp_LUMP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("LUMP object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_LUMP(ACIS_Entity_LUMP *self) +PyObject * +a3dp_LUMP_str(a3dp_LUMP *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -680,92 +433,30 @@ ACIS_Entity_str_LUMP(ACIS_Entity_LUMP *self) return PyUnicode_FromFormat("LUMP object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_LUMP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_LUMP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_LUMP[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_LUMP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LUMP", /* tp_name */ - sizeof(ACIS_Entity_LUMP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_LUMP, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_LUMP, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LUMP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_LUMP, /* tp_methods */ - ACIS_Entity_members_LUMP, /* tp_members */ - ACIS_Entity_getseters_LUMP, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_LUMP, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SHELL wrapper + * SHELL class */ -static int -ACIS_Entity_init_SHELL(ACIS_Entity_SHELL *self, PyObject *args, PyObject *kwargs) +int +a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SHELL(ACIS_Entity_SHELL *self) +PyObject * +a3dp_SHELL_repr(a3dp_SHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SHELL object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SHELL(ACIS_Entity_SHELL *self) +PyObject * +a3dp_SHELL_str(a3dp_SHELL *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -776,92 +467,30 @@ ACIS_Entity_str_SHELL(ACIS_Entity_SHELL *self) return PyUnicode_FromFormat("SHELL object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SHELL", /* tp_name */ - sizeof(ACIS_Entity_SHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SHELL, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SHELL, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SHELL, /* tp_methods */ - ACIS_Entity_members_SHELL, /* tp_members */ - ACIS_Entity_getseters_SHELL, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SHELL, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SUBSHELL wrapper + * SUBSHELL class */ -static int -ACIS_Entity_init_SUBSHELL(ACIS_Entity_SUBSHELL *self, PyObject *args, PyObject *kwargs) +int +a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SUBSHELL(ACIS_Entity_SUBSHELL *self) +PyObject * +a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SUBSHELL object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SUBSHELL(ACIS_Entity_SUBSHELL *self) +PyObject * +a3dp_SUBSHELL_str(a3dp_SUBSHELL *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -872,92 +501,30 @@ ACIS_Entity_str_SUBSHELL(ACIS_Entity_SUBSHELL *self) return PyUnicode_FromFormat("SUBSHELL object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SUBSHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SUBSHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SUBSHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SUBSHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SUBSHELL", /* tp_name */ - sizeof(ACIS_Entity_SUBSHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SUBSHELL, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SUBSHELL, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SUBSHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SUBSHELL, /* tp_methods */ - ACIS_Entity_members_SUBSHELL, /* tp_members */ - ACIS_Entity_getseters_SUBSHELL, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SUBSHELL, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - COEDGE wrapper + * COEDGE class */ -static int -ACIS_Entity_init_COEDGE(ACIS_Entity_COEDGE *self, PyObject *args, PyObject *kwargs) +int +a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_COEDGE(ACIS_Entity_COEDGE *self) +PyObject * +a3dp_COEDGE_repr(a3dp_COEDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("COEDGE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_COEDGE(ACIS_Entity_COEDGE *self) +PyObject * +a3dp_COEDGE_str(a3dp_COEDGE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -968,92 +535,31 @@ ACIS_Entity_str_COEDGE(ACIS_Entity_COEDGE *self) return PyUnicode_FromFormat("COEDGE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_COEDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_COEDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_COEDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_COEDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.COEDGE", /* tp_name */ - sizeof(ACIS_Entity_COEDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_COEDGE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_COEDGE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS COEDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_COEDGE, /* tp_methods */ - ACIS_Entity_members_COEDGE, /* tp_members */ - ACIS_Entity_getseters_COEDGE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_COEDGE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - LOOP wrapper + * LOOP class */ -static int -ACIS_Entity_init_LOOP(ACIS_Entity_LOOP *self, PyObject *args, PyObject *kwargs) +int +a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_LOOP(ACIS_Entity_LOOP *self) +PyObject * +a3dp_LOOP_repr(a3dp_LOOP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("LOOP object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_LOOP(ACIS_Entity_LOOP *self) +PyObject * +a3dp_LOOP_str(a3dp_LOOP *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1064,92 +570,30 @@ ACIS_Entity_str_LOOP(ACIS_Entity_LOOP *self) return PyUnicode_FromFormat("LOOP object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_LOOP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_LOOP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_LOOP[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_LOOP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LOOP", /* tp_name */ - sizeof(ACIS_Entity_LOOP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_LOOP, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_LOOP, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LOOP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_LOOP, /* tp_methods */ - ACIS_Entity_members_LOOP, /* tp_members */ - ACIS_Entity_getseters_LOOP, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_LOOP, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - VERTEX wrapper + * VERTEX class */ -static int -ACIS_Entity_init_VERTEX(ACIS_Entity_VERTEX *self, PyObject *args, PyObject *kwargs) +int +a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_VERTEX(ACIS_Entity_VERTEX *self) +PyObject * +a3dp_VERTEX_repr(a3dp_VERTEX *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("VERTEX object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_VERTEX(ACIS_Entity_VERTEX *self) +PyObject * +a3dp_VERTEX_str(a3dp_VERTEX *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1160,92 +604,30 @@ ACIS_Entity_str_VERTEX(ACIS_Entity_VERTEX *self) return PyUnicode_FromFormat("VERTEX object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_VERTEX[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_VERTEX[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_VERTEX[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_VERTEX = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.VERTEX", /* tp_name */ - sizeof(ACIS_Entity_VERTEX), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_VERTEX, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_VERTEX, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS VERTEX class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_VERTEX, /* tp_methods */ - ACIS_Entity_members_VERTEX, /* tp_members */ - ACIS_Entity_getseters_VERTEX, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_VERTEX, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SURFACE wrapper + * SURFACE class */ -static int -ACIS_Entity_init_SURFACE(ACIS_Entity_SURFACE *self, PyObject *args, PyObject *kwargs) +int +a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SURFACE(ACIS_Entity_SURFACE *self) +PyObject * +a3dp_SURFACE_repr(a3dp_SURFACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SURFACE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SURFACE(ACIS_Entity_SURFACE *self) +PyObject * +a3dp_SURFACE_str(a3dp_SURFACE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1256,21 +638,21 @@ ACIS_Entity_str_SURFACE(ACIS_Entity_SURFACE *self) return PyUnicode_FromFormat("SURFACE object (%s)", acis_obj_status); } -static PyObject * -ACIS_Entity_method_SURFACE_equation(ACIS_Entity_SURFACE *self) +PyObject * +a3dp_SURFACE__equation(a3dp_SURFACE *self) { - PyObject *_retobj = _ACIS_new_surface(); - *((ACIS_Entity_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->equation(); + PyObject *_retobj = _PyNew_surface(); + *((a3dp_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->equation(); return _retobj; } -static PyObject * -ACIS_Entity_method_SURFACE_trans_surface(ACIS_Entity_SURFACE *self, PyObject *args, PyObject *kwargs) +PyObject * +a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) { PyObject *input_t = NULL, *input_reverse = NULL; // List of keyword arguments that this function can take - static char *kwlist[] = + char *kwlist[] = { (char *) "t", (char *) "reverse", @@ -1285,13 +667,13 @@ ACIS_Entity_method_SURFACE_trans_surface(ACIS_Entity_SURFACE *self, PyObject *ar if (input_t != NULL) { // Validate input - if (!_ACIS_check_SPAtransf(input_t)) + if (!_PyCheck_SPAtransf(input_t)) { PyErr_SetString(PyExc_TypeError, "The first argument (t) must be a SPAtransf object"); return NULL; } - _t = *((ACIS_GeometricAtoms_SPAtransf *) input_t)->_acis_obj; + _t = *((a3dp_SPAtransf *) input_t)->_acis_obj; } logical _reverse = FALSE; @@ -1301,99 +683,35 @@ ACIS_Entity_method_SURFACE_trans_surface(ACIS_Entity_SURFACE *self, PyObject *ar _reverse = (_py_inp_reverse == 0) ? FALSE : TRUE; } - PyObject *_retobj = _ACIS_new_surface(); - ((ACIS_Entity_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->trans_surface(_t, _reverse); + PyObject *_retobj = _PyNew_surface(); + ((a3dp_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->trans_surface(_t, _reverse); return _retobj; } -static PyGetSetDef - ACIS_Entity_getseters_SURFACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SURFACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SURFACE[] = - { - { "equation", (PyCFunction) ACIS_Entity_method_SURFACE_equation, METH_NOARGS, "Returns the equation of this SURFACE" }, - { "trans_surface", (PyCFunction) ACIS_Entity_method_SURFACE_trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SURFACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SURFACE", /* tp_name */ - sizeof(ACIS_Entity_SURFACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SURFACE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SURFACE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SURFACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SURFACE, /* tp_methods */ - ACIS_Entity_members_SURFACE, /* tp_members */ - ACIS_Entity_getseters_SURFACE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SURFACE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - CONE wrapper + * CONE class */ -static int -ACIS_Entity_init_CONE(ACIS_Entity_CONE *self, PyObject *args, PyObject *kwargs) +int +a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_CONE(ACIS_Entity_CONE *self) +PyObject * +a3dp_CONE_repr(a3dp_CONE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("CONE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_CONE(ACIS_Entity_CONE *self) +PyObject * +a3dp_CONE_str(a3dp_CONE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1404,92 +722,30 @@ ACIS_Entity_str_CONE(ACIS_Entity_CONE *self) return PyUnicode_FromFormat("CONE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_CONE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_CONE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_CONE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_CONE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.CONE", /* tp_name */ - sizeof(ACIS_Entity_CONE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_CONE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_CONE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS CONE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_CONE, /* tp_methods */ - ACIS_Entity_members_CONE, /* tp_members */ - ACIS_Entity_getseters_CONE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_CONE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - PLANE wrapper + * PLANE class */ -static int -ACIS_Entity_init_PLANE(ACIS_Entity_PLANE *self, PyObject *args, PyObject *kwargs) +int +a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_PLANE(ACIS_Entity_PLANE *self) +PyObject * +a3dp_PLANE_repr(a3dp_PLANE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("PLANE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_PLANE(ACIS_Entity_PLANE *self) +PyObject * +a3dp_PLANE_str(a3dp_PLANE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1500,92 +756,30 @@ ACIS_Entity_str_PLANE(ACIS_Entity_PLANE *self) return PyUnicode_FromFormat("PLANE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_PLANE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_PLANE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_PLANE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_PLANE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.PLANE", /* tp_name */ - sizeof(ACIS_Entity_PLANE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_PLANE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_PLANE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS PLANE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_PLANE, /* tp_methods */ - ACIS_Entity_members_PLANE, /* tp_members */ - ACIS_Entity_getseters_PLANE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_PLANE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SPHERE wrapper + * SPHERE class */ -static int -ACIS_Entity_init_SPHERE(ACIS_Entity_SPHERE *self, PyObject *args, PyObject *kwargs) +int +a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SPHERE(ACIS_Entity_SPHERE *self) +PyObject * +a3dp_SPHERE_repr(a3dp_SPHERE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SPHERE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SPHERE(ACIS_Entity_SPHERE *self) +PyObject * +a3dp_SPHERE_str(a3dp_SPHERE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1596,92 +790,30 @@ ACIS_Entity_str_SPHERE(ACIS_Entity_SPHERE *self) return PyUnicode_FromFormat("SPHERE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SPHERE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SPHERE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SPHERE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SPHERE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPHERE", /* tp_name */ - sizeof(ACIS_Entity_SPHERE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SPHERE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SPHERE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPHERE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SPHERE, /* tp_methods */ - ACIS_Entity_members_SPHERE, /* tp_members */ - ACIS_Entity_getseters_SPHERE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SPHERE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SPLINE wrapper + * SPLINE class */ -static int -ACIS_Entity_init_SPLINE(ACIS_Entity_SPLINE *self, PyObject *args, PyObject *kwargs) +int +a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SPLINE(ACIS_Entity_SPLINE *self) +PyObject * +a3dp_SPLINE_repr(a3dp_SPLINE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SPLINE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SPLINE(ACIS_Entity_SPLINE *self) +PyObject * +a3dp_SPLINE_str(a3dp_SPLINE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1692,92 +824,30 @@ ACIS_Entity_str_SPLINE(ACIS_Entity_SPLINE *self) return PyUnicode_FromFormat("SPLINE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SPLINE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SPLINE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SPLINE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SPLINE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPLINE", /* tp_name */ - sizeof(ACIS_Entity_SPLINE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SPLINE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SPLINE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPLINE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SPLINE, /* tp_methods */ - ACIS_Entity_members_SPLINE, /* tp_members */ - ACIS_Entity_getseters_SPLINE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SPLINE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - TORUS wrapper + * TORUS class */ -static int -ACIS_Entity_init_TORUS(ACIS_Entity_TORUS *self, PyObject *args, PyObject *kwargs) +int +a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_TORUS(ACIS_Entity_TORUS *self) +PyObject * +a3dp_TORUS_repr(a3dp_TORUS *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("TORUS object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_TORUS(ACIS_Entity_TORUS *self) +PyObject * +a3dp_TORUS_str(a3dp_TORUS *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1788,80 +858,18 @@ ACIS_Entity_str_TORUS(ACIS_Entity_TORUS *self) return PyUnicode_FromFormat("TORUS object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_TORUS[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_TORUS[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_TORUS[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_TORUS = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.TORUS", /* tp_name */ - sizeof(ACIS_Entity_TORUS), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_TORUS, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_TORUS, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS TORUS class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_TORUS, /* tp_methods */ - ACIS_Entity_members_TORUS, /* tp_members */ - ACIS_Entity_getseters_TORUS, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_TORUS, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - surface wrapper + * surface class */ -static void -ACIS_Entity_dealloc_surface(ACIS_Entity_surface *self) +void +a3dp_surface_dealloc(a3dp_surface *self) { Py_TYPE(self)->tp_free((PyObject *) self); } -static PyObject * -ACIS_Entity_new_surface(PyTypeObject *type, PyObject *args, PyObject *kwargs) +PyObject * +a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started if (!is_modeler_started()) @@ -1870,9 +878,9 @@ ACIS_Entity_new_surface(PyTypeObject *type, PyObject *args, PyObject *kwargs) return NULL; } - ACIS_Entity_surface *self; + a3dp_surface *self; - self = (ACIS_Entity_surface *) type->tp_alloc(type, 0); + self = (a3dp_surface *) type->tp_alloc(type, 0); if (self != NULL) { // Just getting rid of the dangling pointer @@ -1882,16 +890,16 @@ ACIS_Entity_new_surface(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -static int -ACIS_Entity_init_surface(ACIS_Entity_surface *self, PyObject *args, PyObject *kwargs) +int +a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs) { return 0; } -static PyObject * -ACIS_Entity_method_surface_eval_normal(ACIS_Entity_surface *self, PyObject *arg) +PyObject * +a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg) { - if (!_ACIS_check_SPApar_pos(arg)) + if (!_PyCheck_SPApar_pos(arg)) { PyErr_SetString(PyExc_TypeError, "Expecting a SPApar_pos object"); return NULL; @@ -1899,22 +907,22 @@ ACIS_Entity_method_surface_eval_normal(ACIS_Entity_surface *self, PyObject *arg) Py_INCREF(arg); - SPApar_pos *&_pos = ((ACIS_GeometricAtoms_SPApar_pos *) arg)->_acis_obj; + SPApar_pos *&_pos = ((a3dp_SPApar_pos *) arg)->_acis_obj; SPAunit_vector _retval = self->_acis_obj->eval_normal(*_pos); - PyObject *_retobj = _ACIS_new_SPAunit_vector(); - *((ACIS_GeometricAtoms_SPAunit_vector *) _retobj)->_acis_obj = _retval; + PyObject *_retobj = _PyNew_SPAunit_vector(); + *((a3dp_SPAunit_vector *) _retobj)->_acis_obj = _retval; Py_DECREF(arg); return _retobj; } -static PyObject * -ACIS_Entity_method_surface_eval_position(ACIS_Entity_surface *self, PyObject *arg) +PyObject * +a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg) { - if (!_ACIS_check_SPApar_pos(arg)) + if (!_PyCheck_SPApar_pos(arg)) { PyErr_SetString(PyExc_TypeError, "Expecting a SPApar_pos object"); return NULL; @@ -1922,432 +930,540 @@ ACIS_Entity_method_surface_eval_position(ACIS_Entity_surface *self, PyObject *ar Py_INCREF(arg); - SPApar_pos *&_pos = ((ACIS_GeometricAtoms_SPApar_pos *) arg)->_acis_obj; + SPApar_pos *&_pos = ((a3dp_SPApar_pos *) arg)->_acis_obj; SPAposition _retval = self->_acis_obj->eval_position(*_pos); - PyObject *_retobj = _ACIS_new_SPAposition(); - *((ACIS_GeometricAtoms_SPAposition *) _retobj)->_acis_obj = _retval; + PyObject *_retobj = _PyNew_SPAposition(); + *((a3dp_SPAposition *) _retobj)->_acis_obj = _retval; Py_DECREF(arg); return _retobj; } -static PyGetSetDef - ACIS_Entity_getseters_surface[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_surface[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_surface[] = - { - { "eval_normal", (PyCFunction) ACIS_Entity_method_surface_eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, - { "eval_position", (PyCFunction) ACIS_Entity_method_surface_eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, - { NULL } /* Sentinel */ - }; +PyObject *_PyNew_ENTITY() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_ENTITY, NULL); +} -static PyTypeObject - ACIS_Entity_type_surface = +bool _PyCheck_ENTITY(PyObject *ob) +{ + int retval = PyObject_IsInstance(ob, (PyObject *) &a3dp_type_ENTITY); + if (retval < 0) { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.surface", /* tp_name */ - sizeof(ACIS_Entity_surface), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Entity_dealloc_surface, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS surface class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_surface, /* tp_methods */ - ACIS_Entity_members_surface, /* tp_members */ - ACIS_Entity_getseters_surface, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_surface, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Entity_new_surface, /* tp_new */ - }; - - -/* - * Python Module Definitions - */ - -// Module documentation can be accessible via __doc__ -const char *module_name = "Entity"; -const char *module_documentation = "Contains 3D ACIS Modeler entities, such as BODY, FACE, WIRE, etc."; + PyErr_SetString(PyExc_TypeError, "Problem with ENTITY type cheking"); + return false; + } + return retval != 0; +} -static PyModuleDef - ACIS_Entity_module = - { - PyModuleDef_HEAD_INIT, - module_name, - module_documentation, - -1, - NULL, NULL, NULL, NULL, NULL - }; - -PyMODINIT_FUNC -PyInit_Entity(void) -{ - // Create a Python module, ACIS.Topology - PyObject *m; - m = PyModule_Create(&ACIS_Entity_module); - if (m == NULL) - return NULL; +PyObject *_PyNew_BODY() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_BODY, NULL); +} - // Add ENTITY to the module - if (PyType_Ready(&ACIS_Entity_type_ENTITY) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_ENTITY); - PyModule_AddObject(m, "ENTITY", (PyObject *) &ACIS_Entity_type_ENTITY); +bool _PyCheck_BODY(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_BODY; +} - // Add BODY to the module - ACIS_Entity_type_BODY.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_BODY) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_BODY); - PyModule_AddObject(m, "BODY", (PyObject *) &ACIS_Entity_type_BODY); +PyObject *_PyNew_FACE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_FACE, NULL); +} - // Add FACE to the module - ACIS_Entity_type_FACE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_FACE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_FACE); - PyModule_AddObject(m, "FACE", (PyObject *) &ACIS_Entity_type_FACE); +bool _PyCheck_FACE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_FACE; +} - // Add EDGE to the module - ACIS_Entity_type_EDGE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_EDGE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_EDGE); - PyModule_AddObject(m, "EDGE", (PyObject *) &ACIS_Entity_type_EDGE); +PyObject *_PyNew_EDGE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_EDGE, NULL); +} - // Add WIRE to the module - ACIS_Entity_type_WIRE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_WIRE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_WIRE); - PyModule_AddObject(m, "WIRE", (PyObject *) &ACIS_Entity_type_WIRE); +bool _PyCheck_EDGE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_EDGE; +} - // Add LUMP to the module - ACIS_Entity_type_LUMP.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_LUMP) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_LUMP); - PyModule_AddObject(m, "LUMP", (PyObject *) &ACIS_Entity_type_LUMP); +PyObject *_PyNew_WIRE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_WIRE, NULL); +} - // Add SHELL to the module - ACIS_Entity_type_SHELL.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SHELL) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SHELL); - PyModule_AddObject(m, "SHELL", (PyObject *) &ACIS_Entity_type_SHELL); +bool _PyCheck_WIRE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_WIRE; +} - // Add SUBSHELL to the module - ACIS_Entity_type_SUBSHELL.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SUBSHELL) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SUBSHELL); - PyModule_AddObject(m, "SUBSHELL", (PyObject *) &ACIS_Entity_type_SUBSHELL); +PyObject *_PyNew_LUMP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_LUMP, NULL); +} - // Add COEDGE to the module - ACIS_Entity_type_COEDGE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_COEDGE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_COEDGE); - PyModule_AddObject(m, "COEDGE", (PyObject *) &ACIS_Entity_type_COEDGE); +bool _PyCheck_LUMP(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_LUMP; +} - // Add LOOP to the module - ACIS_Entity_type_LOOP.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_LOOP) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_LOOP); - PyModule_AddObject(m, "LOOP", (PyObject *) &ACIS_Entity_type_LOOP); +PyObject *_PyNew_SHELL() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SHELL, NULL); +} - // Add VERTEX to the module - ACIS_Entity_type_VERTEX.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_VERTEX) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_VERTEX); - PyModule_AddObject(m, "VERTEX", (PyObject *) &ACIS_Entity_type_VERTEX); +bool _PyCheck_SHELL(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SHELL; +} - // Add SURFACE to the module - ACIS_Entity_type_SURFACE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SURFACE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SURFACE); - PyModule_AddObject(m, "SURFACE", (PyObject *) &ACIS_Entity_type_SURFACE); +PyObject *_PyNew_SUBSHELL() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SUBSHELL, NULL); +} - // Add CONE to the module - ACIS_Entity_type_CONE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_CONE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_CONE); - PyModule_AddObject(m, "CONE", (PyObject *) &ACIS_Entity_type_CONE); +bool _PyCheck_SUBSHELL(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SUBSHELL; +} - // Add PLANE to the module - ACIS_Entity_type_PLANE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_PLANE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_PLANE); - PyModule_AddObject(m, "PLANE", (PyObject *) &ACIS_Entity_type_PLANE); +PyObject *_PyNew_COEDGE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_COEDGE, NULL); +} - // Add SPHERE to the module - ACIS_Entity_type_SPHERE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SPHERE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SPHERE); - PyModule_AddObject(m, "SPHERE", (PyObject *) &ACIS_Entity_type_SPHERE); +bool _PyCheck_COEDGE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_COEDGE; +} - // Add SPLINE to the module - ACIS_Entity_type_SPLINE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SPLINE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SPLINE); - PyModule_AddObject(m, "SPLINE", (PyObject *) &ACIS_Entity_type_SPLINE); +PyObject *_PyNew_LOOP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_LOOP, NULL); +} - // Add TORUS to the module - ACIS_Entity_type_TORUS.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_TORUS) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_TORUS); - PyModule_AddObject(m, "TORUS", (PyObject *) &ACIS_Entity_type_TORUS); +bool _PyCheck_LOOP(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_LOOP; +} - // Add surface to the module - if (PyType_Ready(&ACIS_Entity_type_surface) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_surface); - PyModule_AddObject(m, "surface", (PyObject *) &ACIS_Entity_type_surface); +PyObject *_PyNew_VERTEX() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_VERTEX, NULL); +} - // Return the module and all included objects - return m; +bool _PyCheck_VERTEX(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_VERTEX; } -PyObject *_ACIS_new_ENTITY() +PyObject *_PyNew_SURFACE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_ENTITY, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SURFACE, NULL); } -bool _ACIS_check_ENTITY(PyObject *ob) +bool _PyCheck_SURFACE(PyObject *ob) { - int retval = PyObject_IsInstance(ob, (PyObject *) &ACIS_Entity_type_ENTITY); - if (retval < 0) - { - PyErr_SetString(PyExc_TypeError, "Problem with ENTITY type cheking"); - return false; - } - return retval != 0; + return Py_TYPE(ob) == &a3dp_type_SURFACE; } -PyObject *_ACIS_new_BODY() +PyObject *_PyNew_CONE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_BODY, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_CONE, NULL); } -bool _ACIS_check_BODY(PyObject *ob) +bool _PyCheck_CONE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_BODY; + return Py_TYPE(ob) == &a3dp_type_CONE; } -PyObject *_ACIS_new_FACE() +PyObject *_PyNew_PLANE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_FACE, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_PLANE, NULL); } -bool _ACIS_check_FACE(PyObject *ob) +bool _PyCheck_PLANE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_FACE; + return Py_TYPE(ob) == &a3dp_type_PLANE; } -PyObject *_ACIS_new_EDGE() +PyObject *_PyNew_SPHERE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_EDGE, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SPHERE, NULL); } -bool _ACIS_check_EDGE(PyObject *ob) +bool _PyCheck_SPHERE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_EDGE; + return Py_TYPE(ob) == &a3dp_type_SPHERE; } -PyObject *_ACIS_new_WIRE() +PyObject *_PyNew_SPLINE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_WIRE, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SPLINE, NULL); } -bool _ACIS_check_WIRE(PyObject *ob) +bool _PyCheck_SPLINE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_WIRE; + return Py_TYPE(ob) == &a3dp_type_SPLINE; } -PyObject *_ACIS_new_LUMP() +PyObject *_PyNew_TORUS() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_LUMP, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_TORUS, NULL); } -bool _ACIS_check_LUMP(PyObject *ob) +bool _PyCheck_TORUS(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_LUMP; + return Py_TYPE(ob) == &a3dp_type_TORUS; } -PyObject *_ACIS_new_SHELL() +PyObject *_PyNew_surface() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SHELL, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_surface, NULL); } -bool _ACIS_check_SHELL(PyObject *ob) +bool _PyCheck_surface(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_SHELL; + return Py_TYPE(ob) == &a3dp_type_surface; } -PyObject *_ACIS_new_SUBSHELL() +void _a3dp_make_null(PyObject *ob) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SUBSHELL, NULL); + if (_PyCheck_ENTITY(ob)) + { + ((a3dp_ENTITY *) ob)->_acis_obj = NULL; + } } -bool _ACIS_check_SUBSHELL(PyObject *ob) +void _a3dp_set_entity(PyObject *ob, ENTITY *ent) { - return Py_TYPE(ob) == &ACIS_Entity_type_SUBSHELL; + ((a3dp_ENTITY *)ob)->_acis_obj = ent; } -PyObject *_ACIS_new_COEDGE() +/** + * ENTITY_LIST class + */ + +void +a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_COEDGE, NULL); + // First, clear the contents of the ENTITY_LIST instance + self->_acis_obj->clear(); + + // Use ACIS_DELETE macro for ENTITY_LIST + ACIS_DELETE self->_acis_obj; + + // Delete the python object itself + Py_TYPE(self)->tp_free((PyObject *) self); } -bool _ACIS_check_COEDGE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - return Py_TYPE(ob) == &ACIS_Entity_type_COEDGE; + a3dp_ENTITY_LIST *self; + + self = (a3dp_ENTITY_LIST *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; } -PyObject *_ACIS_new_LOOP() +int +a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_LOOP, NULL); + // ENTITY_LIST takes no arguments, so parsing is necessary + self->_acis_obj = ACIS_NEW ENTITY_LIST(); + return 0; } -bool _ACIS_check_LOOP(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_LOOP; + self->_acis_obj->init(); + Py_RETURN_NONE; } -PyObject *_ACIS_new_VERTEX() +PyObject * +a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_VERTEX, NULL); + self->_acis_obj->clear(); + Py_RETURN_NONE; } -bool _ACIS_check_VERTEX(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg) { - return Py_TYPE(ob) == &ACIS_Entity_type_VERTEX; + // Treat arg as a borrowed reference + Py_INCREF(arg); + + int index = -1; + + if (!_PyCheck_ENTITY(arg)) + { + if (!_PyCheck_ENTITY_LIST(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY or ENTITY_LIST object"); + return NULL; + } + else + { + // This function returns void + self->_acis_obj->add(*((a3dp_ENTITY_LIST *) arg)->_acis_obj); + } + } + else + { + // This function returns the added ENTITY's index number + index = self->_acis_obj->add(((a3dp_ENTITY *) arg)->_acis_obj); + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + if (index != -1) + { + return PyLong_FromLong(index); + } + else + { + Py_RETURN_NONE; + } } -PyObject *_ACIS_new_SURFACE() +PyObject * +a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SURFACE, NULL); + // Treat arg as a borrowed reference + Py_INCREF(arg); + + int index = -1; + + if (!_PyCheck_ENTITY(arg)) + { + if (!_PyCheck_ENTITY_LIST(arg)) + { + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY, an ENTITY_LIST or an integer object"); + return NULL; + } + else + { + // This function returns the index number + index = self->_acis_obj->remove((int) PyLong_AsLong(arg)); + } + } + else + { + // This function returns void + self->_acis_obj->remove(*((a3dp_ENTITY_LIST *) arg)->_acis_obj); + } + } + else + { + // This function returns the removed ENTITY's index number + index = self->_acis_obj->remove(((a3dp_ENTITY *) arg)->_acis_obj); + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + if (index != -1) + { + return PyLong_FromLong(index); + } + else + { + Py_RETURN_NONE; + } } -bool _ACIS_check_SURFACE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_SURFACE; + return PyLong_FromLong(self->_acis_obj->count()); } -PyObject *_ACIS_new_CONE() +PyObject * +a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_CONE, NULL); + return PyLong_FromLong(self->_acis_obj->iteration_count()); } -bool _ACIS_check_CONE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_CONE; + self->_acis_obj->reverse(); + Py_RETURN_NONE; } -PyObject *_ACIS_new_PLANE() +PyObject * +a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_PLANE, NULL); + // Treat arg as a borrowed reference + Py_INCREF(arg); + + if (!_PyCheck_ENTITY(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY object"); + return NULL; + } + + int index = self->_acis_obj->lookup(((a3dp_ENTITY *) arg)->_acis_obj); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + return PyLong_FromLong(index); } -bool _ACIS_check_PLANE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_PLANE; + return PyLong_FromLong(self->_acis_obj->byte_count()); } -PyObject *_ACIS_new_SPHERE() +PyObject * +a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SPHERE, NULL); + ENTITY *_elem = self->_acis_obj->first(); + PyObject *retobj = __convert_entity(_elem); + return retobj; } -bool _ACIS_check_SPHERE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_SPHERE; + PyObject *retobj; + ENTITY *_elem = self->_acis_obj->next(); + + if (_elem) + { + retobj = __convert_entity(_elem); + } + else + { + // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + return retobj; } -PyObject *_ACIS_new_SPLINE() +PyObject * +a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SPLINE, NULL); + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an integer object"); + return NULL; + } + + Py_INCREF(arg); + int _from_index = (int) PyLong_AsLong(arg); + Py_DECREF(arg); + + PyObject *retobj; + ENTITY *_elem = self->_acis_obj->next_from(_from_index); + + if (_elem) + { + retobj = __convert_entity(_elem); + } + else + { + // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + return retobj; } -bool _ACIS_check_SPLINE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_SPLINE; + /* This function will create a Python generator/iterator */ + + // Reference increment is necessary, otherwise this ENTITY_LIST will be garbage collected + Py_INCREF(self); + + // Iterator/Generator creation functions always return self! + return (PyObject *) self; } -PyObject *_ACIS_new_TORUS() +PyObject * +a3dp_ENTITYLIST_iter(PyObject *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_TORUS, NULL); + /* Must have the same signature as PyObject_GetIter() */ + + // Move the ENTITY_LIST pointer to the beginning + a3dp_ENTITYLIST__init((a3dp_ENTITY_LIST *) self); + + Py_INCREF(self); + return self; } -bool _ACIS_check_TORUS(PyObject *ob) +PyObject * +a3dp_ENTITYLIST_iter_next(PyObject *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_TORUS; + /* Must have the same signature as PyIter_Next() */ + + // Convert the input argument to a ENTITY_LIST object + a3dp_ENTITY_LIST *_ent_list = (a3dp_ENTITY_LIST *) self; + + // Return the next element + return a3dp_ENTITYLIST__next(_ent_list); } -PyObject *_ACIS_new_surface() + +PyObject * +_PyNew_ENTITY_LIST() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_surface, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_ENTITYLIST, NULL); } -bool _ACIS_check_surface(PyObject *ob) +bool +_PyCheck_ENTITY_LIST(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_surface; + if (Py_TYPE(ob) == &a3dp_type_ENTITYLIST) + return true; + else + return false; } -void _ACIS_make_null(PyObject *ob) +PyObject * +__convert_entity(ENTITY *ent) { - if (_ACIS_check_ENTITY(ob)) + // Find the type name of the entity + const char *_type_name = ent->type_name(); + + // We could use a hashing function here... + PyObject *_retobj; + if (strcmp("body", _type_name) == 0) { - ((ACIS_Entity_ENTITY *) ob)->_acis_obj = NULL; + _retobj = _PyNew_BODY(); + _a3dp_set_entity(_retobj, ent); + } + else if (strcmp("face", _type_name) == 0) + { + _retobj = _PyNew_FACE(); + _a3dp_set_entity(_retobj, ent); + } + else if (strcmp("surface", _type_name) == 0) + { + _retobj = _PyNew_SURFACE(); + _a3dp_set_entity(_retobj, ent); } -} -void _ACIS_set_entity(PyObject *ob, ENTITY *ent) -{ - ((ACIS_Entity_ENTITY *)ob)->_acis_obj = ent; + return _retobj; } diff --git a/src/acis_entity.h b/src/acis_entity.h index 6e33c32..7743a66 100644 --- a/src/acis_entity.h +++ b/src/acis_entity.h @@ -9,24 +9,14 @@ * */ -#ifndef ACIS_ENTITY_H -#define ACIS_ENTITY_H +#ifndef A3DPY_ENTITY_H +#define A3DPY_ENTITY_H #include #include -#include "kernapi.hxx" -#include -#include -#include -#include -#include -#include -#include - -#include "acis_geometric_atoms.h" - -#include "acis_entity_export.h" +#include "acis_includes.h" +#include "acis_operators.h" #ifdef __cplusplus @@ -42,72 +32,55 @@ typedef struct ENTITY *_acis_obj; PyObject *attrib_name; PyObject *attrib_object_id; -} ACIS_Entity_ENTITY; - -int ACIS_ENTITY_EXPORT ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg); - -int ACIS_ENTITY_EXPORT ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self); - -void ACIS_ENTITY_EXPORT ACIS_Entity_dealloc_ENTITY(ACIS_Entity_ENTITY *self); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs); - -int ACIS_ENTITY_EXPORT ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwargs); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_type_name(PyObject *self); +} a3dp_ENTITY; + +int a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg); +int a3dp_ENTITY_clear(a3dp_ENTITY *self); +void a3dp_ENTITY_dealloc(a3dp_ENTITY *self); +PyObject *a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_ENTITY_repr(a3dp_ENTITY *self); +PyObject *a3dp_ENTITY_str(a3dp_ENTITY *self); +PyObject *a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); +int a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); +PyObject *a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); +int a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); +PyObject *a3dp_ENTITY_type_name(PyObject *self); static PyGetSetDef - ACIS_Entity_getseters_ENTITY[] = - { - { (char *) "name", (getter) ACIS_Entity_method_ENTITY_get_attrib_name, (setter) ACIS_Entity_method_ENTITY_set_attrib_name, (char *) "object name", NULL }, - { (char *) "id", (getter) ACIS_Entity_method_ENTITY_get_attrib_obj_id, (setter) ACIS_Entity_method_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_ENTITY[] = + a3dp_getseters_ENTITY[] = { + { (char *) "name", (getter) a3dp_ENTITY_get_attrib_name, (setter) a3dp_ENTITY_set_attrib_name, (char *) "object name", NULL }, + { (char *) "id", (getter) a3dp_ENTITY_get_attrib_obj_id, (setter) a3dp_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, { NULL } /* Sentinel */ }; static PyMethodDef - ACIS_Entity_methods_ENTITY[] = + a3dp_methods_ENTITY[] = { - { "type_name", (PyCFunction) ACIS_Entity_method_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, + { "type_name", (PyCFunction) a3dp_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, { NULL } /* Sentinel */ }; static PyTypeObject - ACIS_Entity_type_ENTITY = + a3dp_type_ENTITY = { PyVarObject_HEAD_INIT(NULL, 0) "ACIS.ENTITY", /* tp_name */ - sizeof(ACIS_Entity_ENTITY), /* tp_basicsize */ + sizeof(a3dp_ENTITY), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor) ACIS_Entity_dealloc_ENTITY, /* tp_dealloc */ + (destructor) a3dp_ENTITY_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_ENTITY, /* tp_repr */ + (reprfunc) a3dp_ENTITY_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_ENTITY, /* tp_str */ + (reprfunc) a3dp_ENTITY_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -115,198 +88,1124 @@ static PyTypeObject Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ "ACIS ENTITY class", /* tp_doc */ - (traverseproc) ACIS_Entity_traverse_ENTITY, /* tp_traverse */ - (inquiry) ACIS_Entity_clear_ENTITY, /* tp_clear */ + (traverseproc) a3dp_ENTITY_traverse, /* tp_traverse */ + (inquiry) a3dp_ENTITY_clear, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - ACIS_Entity_methods_ENTITY, /* tp_methods */ - ACIS_Entity_members_ENTITY, /* tp_members */ - ACIS_Entity_getseters_ENTITY, /* tp_getset */ + a3dp_methods_ENTITY, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_ENTITY, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_ENTITY, /* tp_init */ + (initproc) a3dp_ENTITY_init, /* tp_init */ 0, /* tp_alloc */ - ACIS_Entity_new_ENTITY, /* tp_new */ + a3dp_ENTITY_new, /* tp_new */ }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_ENTITY(); +PyObject *_PyNew_ENTITY(); -bool ACIS_ENTITY_EXPORT _ACIS_check_ENTITY(PyObject *ob); +bool _PyCheck_ENTITY(PyObject *ob); // Define BODY typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_BODY; + a3dp_ENTITY base_obj; +} a3dp_BODY; + +int a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_BODY_repr(a3dp_BODY *self); +PyObject *a3dp_BODY_str(a3dp_BODY *self); + +static PyTypeObject + a3dp_type_BODY = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.BODY", /* tp_name */ + sizeof(a3dp_BODY), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_BODY_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_BODY_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS BODY class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_BODY_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_BODY(); -bool ACIS_ENTITY_EXPORT _ACIS_check_BODY(PyObject *ob); +PyObject *_PyNew_BODY(); + +bool _PyCheck_BODY(PyObject *ob); // Define FACE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_FACE; + a3dp_ENTITY base_obj; +} a3dp_FACE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_FACE(); +int a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FACE_repr(a3dp_FACE *self); +PyObject *a3dp_FACE_str(a3dp_FACE *self); +PyObject *a3dp_FACE__sense(a3dp_FACE *self); +PyObject *a3dp_FACE__geometry(a3dp_FACE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_FACE(PyObject *ob); +static PyMethodDef + a3dp_methods_FACE[] = + { + { "sense", (PyCFunction) a3dp_FACE__sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, + { "geometry", (PyCFunction) a3dp_FACE__geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_FACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FACE", /* tp_name */ + sizeof(a3dp_FACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_FACE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_FACE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS FACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_FACE, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_FACE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_FACE(); + +bool _PyCheck_FACE(PyObject *ob); // Define EDGE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_EDGE; + a3dp_ENTITY base_obj; +} a3dp_EDGE; + +int a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_EDGE_repr(a3dp_EDGE *self); +PyObject *a3dp_EDGE_str(a3dp_EDGE *self); + +static PyTypeObject + a3dp_type_EDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.EDGE", /* tp_name */ + sizeof(a3dp_EDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_EDGE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_EDGE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS EDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_EDGE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_EDGE(); +PyObject *_PyNew_EDGE(); -bool ACIS_ENTITY_EXPORT _ACIS_check_EDGE(PyObject *ob); +bool _PyCheck_EDGE(PyObject *ob); // Define WIRE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_WIRE; + a3dp_ENTITY base_obj; +} a3dp_WIRE; + +int a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_WIRE_repr(a3dp_WIRE *self); +PyObject *a3dp_WIRE_str(a3dp_WIRE *self); + +static PyTypeObject + a3dp_type_WIRE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.WIRE", /* tp_name */ + sizeof(a3dp_WIRE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_WIRE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_WIRE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS WIRE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_WIRE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_WIRE(); +PyObject *_PyNew_WIRE(); -bool ACIS_ENTITY_EXPORT _ACIS_check_WIRE(PyObject *ob); +bool _PyCheck_WIRE(PyObject *ob); // Define LUMP typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_LUMP; + a3dp_ENTITY base_obj; +} a3dp_LUMP; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LUMP(); +int a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_LUMP_repr(a3dp_LUMP *self); +PyObject *a3dp_LUMP_str(a3dp_LUMP *self); + +static PyTypeObject + a3dp_type_LUMP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LUMP", /* tp_name */ + sizeof(a3dp_LUMP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_LUMP_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_LUMP_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LUMP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_LUMP_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -bool ACIS_ENTITY_EXPORT _ACIS_check_LUMP(PyObject *ob); + +PyObject *_PyNew_LUMP(); + +bool _PyCheck_LUMP(PyObject *ob); // Define SHELL typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SHELL; + a3dp_ENTITY base_obj; +} a3dp_SHELL; + +int a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SHELL_repr(a3dp_SHELL *self); +PyObject *a3dp_SHELL_str(a3dp_SHELL *self); + +static PyTypeObject + a3dp_type_SHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SHELL", /* tp_name */ + sizeof(a3dp_SHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SHELL_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SHELL_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SHELL_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SHELL(); +PyObject *_PyNew_SHELL(); -bool ACIS_ENTITY_EXPORT _ACIS_check_SHELL(PyObject *ob); +bool _PyCheck_SHELL(PyObject *ob); // Define SUBSHELL typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SUBSHELL; + a3dp_ENTITY base_obj; +} a3dp_SUBSHELL; + +int a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self); +PyObject *a3dp_SUBSHELL_str(a3dp_SUBSHELL *self); + +static PyTypeObject + a3dp_type_SUBSHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SUBSHELL", /* tp_name */ + sizeof(a3dp_SUBSHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SUBSHELL_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SUBSHELL_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SUBSHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SUBSHELL_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SUBSHELL(); +PyObject *_PyNew_SUBSHELL(); -bool ACIS_ENTITY_EXPORT _ACIS_check_SUBSHELL(PyObject *ob); +bool _PyCheck_SUBSHELL(PyObject *ob); // Define COEDGE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_COEDGE; + a3dp_ENTITY base_obj; +} a3dp_COEDGE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_COEDGE(); +int a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_COEDGE_repr(a3dp_COEDGE *self); +PyObject *a3dp_COEDGE_str(a3dp_COEDGE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_COEDGE(PyObject *ob); +static PyTypeObject + a3dp_type_COEDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.COEDGE", /* tp_name */ + sizeof(a3dp_COEDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_COEDGE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_COEDGE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS COEDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_COEDGE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_COEDGE(); + +bool _PyCheck_COEDGE(PyObject *ob); // Define LOOP typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_LOOP; + a3dp_ENTITY base_obj; +} a3dp_LOOP; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LOOP(); +int a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_LOOP_repr(a3dp_LOOP *self); +PyObject *a3dp_LOOP_str(a3dp_LOOP *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_LOOP(PyObject *ob); +static PyTypeObject + a3dp_type_LOOP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LOOP", /* tp_name */ + sizeof(a3dp_LOOP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_LOOP_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_LOOP_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LOOP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_LOOP_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_LOOP(); + +bool _PyCheck_LOOP(PyObject *ob); // Define VERTEX typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_VERTEX; + a3dp_ENTITY base_obj; +} a3dp_VERTEX; + +int a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_VERTEX_repr(a3dp_VERTEX *self); +PyObject *a3dp_VERTEX_str(a3dp_VERTEX *self); + +static PyTypeObject + a3dp_type_VERTEX = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.VERTEX", /* tp_name */ + sizeof(a3dp_VERTEX), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_VERTEX_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_VERTEX_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS VERTEX class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_VERTEX_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_VERTEX(); +PyObject *_PyNew_VERTEX(); -bool ACIS_ENTITY_EXPORT _ACIS_check_VERTEX(PyObject *ob); +bool _PyCheck_VERTEX(PyObject *ob); // Define SURFACE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SURFACE; + a3dp_ENTITY base_obj; +} a3dp_SURFACE; + +int a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SURFACE_repr(a3dp_SURFACE *self); +PyObject *a3dp_SURFACE_str(a3dp_SURFACE *self); +PyObject *a3dp_SURFACE__equation(a3dp_SURFACE *self); +PyObject *a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SURFACE(); +static PyMethodDef + a3dp_methods_SURFACE[] = + { + { "equation", (PyCFunction) a3dp_SURFACE__equation, METH_NOARGS, "Returns the equation of this SURFACE" }, + { "trans_surface", (PyCFunction) a3dp_SURFACE__trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, + { NULL } /* Sentinel */ + }; -bool ACIS_ENTITY_EXPORT _ACIS_check_SURFACE(PyObject *ob); +static PyTypeObject + a3dp_type_SURFACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SURFACE", /* tp_name */ + sizeof(a3dp_SURFACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SURFACE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SURFACE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SURFACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SURFACE, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SURFACE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SURFACE(); + +bool _PyCheck_SURFACE(PyObject *ob); // Define CONE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_CONE; + a3dp_ENTITY base_obj; +} a3dp_CONE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_CONE(); +int a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_CONE_repr(a3dp_CONE *self); +PyObject *a3dp_CONE_str(a3dp_CONE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_CONE(PyObject *ob); +static PyTypeObject + a3dp_type_CONE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.CONE", /* tp_name */ + sizeof(a3dp_CONE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_CONE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_CONE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS CONE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_CONE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_CONE(); + +bool _PyCheck_CONE(PyObject *ob); // Define PLANE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_PLANE; + a3dp_ENTITY base_obj; +} a3dp_PLANE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_PLANE(); +int a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_PLANE_repr(a3dp_PLANE *self); +PyObject *a3dp_PLANE_str(a3dp_PLANE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_PLANE(PyObject *ob); +static PyTypeObject + a3dp_type_PLANE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.PLANE", /* tp_name */ + sizeof(a3dp_PLANE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_PLANE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_PLANE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS PLANE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_PLANE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_PLANE(); + +bool _PyCheck_PLANE(PyObject *ob); // Define SPHERE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SPHERE; + a3dp_ENTITY base_obj; +} a3dp_SPHERE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPHERE(); +int a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPHERE_repr(a3dp_SPHERE *self); +PyObject *a3dp_SPHERE_str(a3dp_SPHERE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_SPHERE(PyObject *ob); +static PyTypeObject + a3dp_type_SPHERE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPHERE", /* tp_name */ + sizeof(a3dp_SPHERE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPHERE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPHERE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPHERE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPHERE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SPHERE(); + +bool _PyCheck_SPHERE(PyObject *ob); // Define SPLINE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SPLINE; + a3dp_ENTITY base_obj; +} a3dp_SPLINE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPLINE(); +int a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPLINE_repr(a3dp_SPLINE *self); +PyObject *a3dp_SPLINE_str(a3dp_SPLINE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_SPLINE(PyObject *ob); +static PyTypeObject + a3dp_type_SPLINE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPLINE", /* tp_name */ + sizeof(a3dp_SPLINE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPLINE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPLINE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPLINE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPLINE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + +PyObject *_PyNew_SPLINE(); + +bool _PyCheck_SPLINE(PyObject *ob); // Define TORUS typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_TORUS; + a3dp_ENTITY base_obj; +} a3dp_TORUS; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_TORUS(); +int a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_TORUS_repr(a3dp_TORUS *self); +PyObject *a3dp_TORUS_str(a3dp_TORUS *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_TORUS(PyObject *ob); +static PyTypeObject + a3dp_type_TORUS = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.TORUS", /* tp_name */ + sizeof(a3dp_TORUS), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_TORUS_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_TORUS_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS TORUS class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_TORUS_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_TORUS(); + +bool _PyCheck_TORUS(PyObject *ob); // Define surface typedef struct { surface* _acis_obj; -} ACIS_Entity_surface; +} a3dp_surface; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_surface(); +void a3dp_surface_dealloc(a3dp_surface *self); +PyObject *a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg); +PyObject *a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg); -bool ACIS_ENTITY_EXPORT _ACIS_check_surface(PyObject *ob); +static PyMethodDef + a3dp_methods_surface[] = + { + { "eval_normal", (PyCFunction) a3dp_surface__eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, + { "eval_position", (PyCFunction) a3dp_surface__eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_surface = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.surface", /* tp_name */ + sizeof(a3dp_surface), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_surface_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS surface class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_surface, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_surface_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_surface_new, /* tp_new */ + }; + +PyObject *_PyNew_surface(); + +bool _PyCheck_surface(PyObject *ob); + +// Define ENTITY_LIST +typedef struct +{ + PyObject_HEAD + ENTITY_LIST *_acis_obj; +} a3dp_ENTITY_LIST; + +void a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST_iter(PyObject *self); +PyObject *a3dp_ENTITYLIST_iter_next(PyObject *self); + +static PyMethodDef + a3dp_methods_ENTITY_LIST[] = + { + { "add", (PyCFunction) a3dp_ENTITYLIST__add, METH_O, "Adds an entity or entities to the list" }, + { "remove", (PyCFunction) a3dp_ENTITYLIST__remove, METH_O, "Removes an entity or entities from the list" }, + { "count", (PyCFunction) a3dp_ENTITYLIST__count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, + { "iteration_count", (PyCFunction) a3dp_ENTITYLIST__iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, + { "init", (PyCFunction) a3dp_ENTITYLIST__init, METH_NOARGS, "Adds an entity or entities to the list" }, + { "clear", (PyCFunction) a3dp_ENTITYLIST__clear, METH_NOARGS, "Clear all entries from the list and reset indexes and counters for reuse" }, + { "lookup", (PyCFunction) a3dp_ENTITYLIST__lookup, METH_O, "Adds an entity or entities to the list" }, + { "reverse", (PyCFunction) a3dp_ENTITYLIST__reverse, METH_NOARGS, "Adds an entity or entities to the list" }, + { "byte_count", (PyCFunction) a3dp_ENTITYLIST__byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, + { "first", (PyCFunction) a3dp_ENTITYLIST__first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, + { "next", (PyCFunction) a3dp_ENTITYLIST__next, METH_NOARGS, "Returns the next undeleted (live) entry" }, + { "next_from", (PyCFunction) a3dp_ENTITYLIST__next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, + { "array", (PyCFunction) a3dp_ENTITYLIST__array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_ENTITYLIST = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.ENTITY_LIST", /* tp_name */ + sizeof(a3dp_ENTITY_LIST), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_ENTITYLIST_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS ENTITY_LIST class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc) a3dp_ENTITYLIST_iter, /* tp_iter */ + (iternextfunc) a3dp_ENTITYLIST_iter_next, /* tp_iternext */ + a3dp_methods_ENTITY_LIST, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_ENTITYLIST_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_ENTITYLIST_new, /* tp_new */ + }; + +PyObject *_PyNew_ENTITY_LIST(); + +bool _PyCheck_ENTITY_LIST(PyObject *ob); + +PyObject *__convert_entity(ENTITY *ent); // Additional functions @@ -315,12 +1214,12 @@ bool ACIS_ENTITY_EXPORT _ACIS_check_surface(PyObject *ob); * Sets the internal ocis_obj variable to NULL * @param ob Topology object, such as ENTITY, BODY, FACE, etc. */ -void ACIS_ENTITY_EXPORT _ACIS_make_null(PyObject *ob); +void _a3dp_make_null(PyObject *ob); -void ACIS_ENTITY_EXPORT _ACIS_set_entity(PyObject *ob, ENTITY *ent); +void _a3dp_set_entity(PyObject *ob, ENTITY *ent); #ifdef __cplusplus } #endif -#endif // !ACIS_ENTITY_H +#endif // !A3DPY_ENTITY_H diff --git a/src/acis_enums.cpp b/src/acis_enums.cpp new file mode 100644 index 0000000..bdb4100 --- /dev/null +++ b/src/acis_enums.cpp @@ -0,0 +1,22 @@ +#include "acis_enums.h" + + +PyObject *_PyNew_NDBOOL_KEEP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_NDBOOLKEEP, NULL); +} + +bool _PyCheck_NDBOOL_KEEP(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_NDBOOLKEEP; +} + +PyObject *_PyNew_sweep_bool_type() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_sweepbooltype, NULL); +} + +bool _PyCheck_sweep_bool_type(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_sweepbooltype; +} diff --git a/src/acis_enums.h b/src/acis_enums.h new file mode 100644 index 0000000..695ac49 --- /dev/null +++ b/src/acis_enums.h @@ -0,0 +1,102 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_ENUMS_H +#define A3DPY_ENUMS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Define NDBOOL_KEEP enum +typedef struct { + PyObject_HEAD +} a3dp_NDBOOL_KEEP; + +/** + * NDBOOL_KEEP enum + */ + +static PyTypeObject + a3dp_type_NDBOOLKEEP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.NDBOOL_KEEP", /* tp_name */ + sizeof(a3dp_NDBOOL_KEEP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ + }; + +PyObject *_PyNew_NDBOOL_KEEP(); +bool _PyCheck_NDBOOL_KEEP(PyObject *ob); + +// Define sweep_bool_type enum +typedef struct { + PyObject_HEAD +} a3dp_sweep_bool_type; + +/** + * sweep_bool_type enum + */ + +static PyTypeObject + a3dp_type_sweepbooltype = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_bool_type", /* tp_name */ + sizeof(a3dp_sweep_bool_type), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "Sweep to body boolean operation type", /* tp_doc */ + }; + +PyObject *_PyNew_sweep_bool_type(); +bool _PyCheck_sweep_bool_type(PyObject *ob); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_ENUMS_H diff --git a/src/acis_geometric_atoms.cpp b/src/acis_geometric_atoms.cpp deleted file mode 100644 index 042a9ce..0000000 --- a/src/acis_geometric_atoms.cpp +++ /dev/null @@ -1,2778 +0,0 @@ -#include "acis_geometric_atoms.h" - - -/** - * SPAposition wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAposition(ACIS_GeometricAtoms_SPAposition *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAposition(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAposition *self; - - self = (ACIS_GeometricAtoms_SPAposition *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAposition(ACIS_GeometricAtoms_SPAposition *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAposition(input_x, input_y, input_z); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPAposition(ACIS_GeometricAtoms_SPAposition *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAposition object (%s, %s, %s)", _x, _y, _z); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_coordinate(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->coordinate(_i)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_coordinate(ACIS_GeometricAtoms_SPAposition *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - static char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The coordinate input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_coordinate(_i, _new_c); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_x(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_y(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_z(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_x(ACIS_GeometricAtoms_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_y(ACIS_GeometricAtoms_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_z(ACIS_GeometricAtoms_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_x_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAposition_x(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_y_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAposition_y(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_z_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAposition_z(self); -} - -static int -ACIS_GeometricAtoms_method_SPAposition_x_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAposition_set_x(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAposition_y_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAposition_set_y(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAposition_z_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAposition_set_z(self, value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAposition[] = - { - { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAposition_x_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, - { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAposition_y_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, - { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAposition_z_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAposition[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAposition[] = - { - { "coordinate", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_coordinate, METH_O, "Returns the i-th component value" }, - { "set_coordinate", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, - { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the x-coordinate value" }, - { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the y-coordinate value" }, - { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the z-coordinate value" }, - { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_x, METH_NOARGS, "Returns the x-coordinate value" }, - { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_y, METH_NOARGS, "Returns the y-coordinate value" }, - { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_z, METH_NOARGS, "Returns the z-coordinate value" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAposition = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAposition", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAposition), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAposition, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAposition, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAposition, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAposition, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAposition, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAposition, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAposition, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAposition, /* tp_new */ - }; - - -/** - * SPAvector wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAvector(ACIS_GeometricAtoms_SPAvector *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAvector(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAvector *self; - - self = (ACIS_GeometricAtoms_SPAvector *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAvector(ACIS_GeometricAtoms_SPAvector *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAvector(input_x, input_y, input_z); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPAvector(ACIS_GeometricAtoms_SPAvector *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAvector object (%s, %s, %s)", _x, _y, _z); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_component(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->component(_i)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_component(ACIS_GeometricAtoms_SPAvector *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - static char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_component(_i, _new_c); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_x(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_y(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_z(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_x(ACIS_GeometricAtoms_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_y(ACIS_GeometricAtoms_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_z(ACIS_GeometricAtoms_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_x_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAvector_x(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_y_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAvector_y(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_z_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAvector_z(self); -} - -static int -ACIS_GeometricAtoms_method_SPAvector_x_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAvector_set_x(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAvector_y_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAvector_set_y(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAvector_z_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAvector_set_z(self, value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAvector[] = - { - { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAvector_x_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAvector_y_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAvector_z_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAvector[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAvector[] = - { - { "component", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAvector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAvector", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAvector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAvector, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAvector, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAvector, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAvector, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAvector, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAvector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAvector, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAvector, /* tp_new */ - }; - - -/** - * SPAunit_vector wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAunit_vector(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAunit_vector *self; - - self = (ACIS_GeometricAtoms_SPAunit_vector *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAunit_vector(input_x, input_y, input_z); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAunit_vector object (%s, %s, %s)", _x, _y, _z); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_component(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->component(_i)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_component(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - static char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_component(_i, _new_c); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_x(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_y(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_z(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_x(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_y(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_z(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_x_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAunit_vector_x(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_y_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAunit_vector_y(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_z_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAunit_vector_z(self); -} - -static int -ACIS_GeometricAtoms_method_SPAunit_vector_x_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAunit_vector_set_x(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAunit_vector_y_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAunit_vector_set_y(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAunit_vector_z_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAunit_vector_set_z(self, value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAunit_vector[] = - { - { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_x_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_y_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_z_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAunit_vector[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAunit_vector[] = - { - { "component", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAunit_vector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAunit_vector", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAunit_vector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAunit_vector, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAunit_vector, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAunit_vector, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAunit_vector, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAunit_vector, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAunit_vector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAunit_vector, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAunit_vector, /* tp_new */ - }; - - -/** - * SPAmatrix wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAmatrix(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAmatrix(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAmatrix *self; - - self = (ACIS_GeometricAtoms_SPAmatrix *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAmatrix(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAmatrix(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_column(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *arg) -{ - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - // Create a new SPAvector python object - PyObject *_python_ret = _ACIS_new_SPAvector(); - - // Convert python input argument into a C variable - int _in_col = (int) PyLong_AsLong(arg); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->column(_in_col); - - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_row(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *arg) -{ - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - // Create a new SPAvector python object - PyObject *_python_ret = _ACIS_new_SPAvector(); - - // Convert python input argument into a C variable - int _in_row = (int) PyLong_AsLong(arg); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->row(_in_row); - - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_inverse(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Create a new SPAmatrix python object - PyObject *_python_ret = _ACIS_new_SPAmatrix(); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->inverse(); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_transpose(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Create a new SPAmatrix python object - PyObject *_python_ret = _ACIS_new_SPAmatrix(); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->transpose(); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_determinant(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Execute the ACIS function and return the value as a python object - return PyFloat_FromDouble(self->_acis_obj->determinant()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_element(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - int input_row, input_col; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "row", - (char *) "col", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_row, &input_col)) - return NULL; - - // Execute the ACIS function and return the value as a python object - return PyFloat_FromDouble(self->_acis_obj->element(input_row, input_col)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_set_element(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - int input_row, input_col; - double input_new_e; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "row", - (char *) "col", - (char *) "new_e", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iid", kwlist, &input_row, &input_col, &input_new_e)) - return NULL; - - // Execute the ACIS function - self->_acis_obj->set_element(input_row, input_col, input_new_e); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_is_identity(ACIS_GeometricAtoms_SPAmatrix *self) -{ - logical _ret_val = self->_acis_obj->is_identity(); - - if (_ret_val) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAmatrix[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAmatrix[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAmatrix[] = - { - { "column", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_column, METH_O, "Extracts a column from this matrix" }, - { "row", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_row, METH_O, "Extracts a row from this matrix" }, - { "element", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, - { "set_element", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, - { "determinant", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_determinant, METH_NOARGS, "Returns the determinant of this matrix" }, - { "transpose", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_transpose, METH_NOARGS, "Returns a transpose of this matrix" }, - { "inverse", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_inverse, METH_NOARGS, "Returns the inverse of this matrix" }, - { "is_identity", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAmatrix = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAmatrix", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAmatrix), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAmatrix, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAmatrix, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAmatrix, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAmatrix, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAmatrix, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAmatrix, /* tp_new */ - }; - - -/** - * SPAtransf wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAtransf(ACIS_GeometricAtoms_SPAtransf *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAtransf(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAtransf *self; - - self = (ACIS_GeometricAtoms_SPAtransf *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAtransf(ACIS_GeometricAtoms_SPAtransf *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAtransf(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_affine(ACIS_GeometricAtoms_SPAtransf *self) -{ - PyObject *_ret = _ACIS_new_SPAmatrix(); - - *((ACIS_GeometricAtoms_SPAmatrix *) _ret)->_acis_obj = self->_acis_obj->affine(); - - return _ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_inverse(ACIS_GeometricAtoms_SPAtransf *self) -{ - PyObject *_ret = _ACIS_new_SPAtransf(); - - *((ACIS_GeometricAtoms_SPAtransf *) _ret)->_acis_obj = self->_acis_obj->inverse(); - - return _ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_translation(ACIS_GeometricAtoms_SPAtransf *self) -{ - PyObject *_ret = _ACIS_new_SPAvector(); - - *((ACIS_GeometricAtoms_SPAvector *) _ret)->_acis_obj = self->_acis_obj->translation(); - - return _ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_identity(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->identity(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_reflect(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->reflect(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_rotate(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->rotate(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_scaling(ACIS_GeometricAtoms_SPAtransf *self) -{ - return PyFloat_FromDouble(self->_acis_obj->scaling()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_shear(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->shear(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAtransf[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAtransf[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAtransf[] = - { - { "affine", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_affine, METH_NOARGS, "Returns the affine portion of the transformation" }, - { "inverse", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_inverse, METH_NOARGS, "Returns the inverse transformation" }, - { "translation", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, - { "identity", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, - { "reflect", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, - { "rotate", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, - { "scaling", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, - { "shear", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAtransf = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAtransf), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAtransf, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAtransf represents a general 3D affine transformation", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAtransf, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAtransf, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAtransf, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAtransf, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAtransf, /* tp_new */ - }; - - -/** - * SPApar_pos wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPApar_pos(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPApar_pos *self; - - self = (ACIS_GeometricAtoms_SPApar_pos *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPApar_pos(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self) -{ - double u = self->_acis_obj->u; double v = self->_acis_obj->v; - - char *_u = PyOS_double_to_string(u, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_u) - return PyErr_NoMemory(); - - char *_v = PyOS_double_to_string(v, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_v) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPApar_pos object (%s, %s)", _u, _v); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_pos_u_getter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->u); -} - -static int -ACIS_GeometricAtoms_method_SPApar_pos_u_setter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - self->_acis_obj->u = PyFloat_AsDouble(value); - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_pos_v_getter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->v); -} - -static int -ACIS_GeometricAtoms_method_SPApar_pos_v_setter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - self->_acis_obj->v = PyFloat_AsDouble(value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPApar_pos[] = - { - { (char *) "u", (getter) ACIS_GeometricAtoms_method_SPApar_pos_u_getter, (setter) ACIS_GeometricAtoms_method_SPApar_pos_u_setter, (char *) "value of the u parameter", NULL }, - { (char *) "v", (getter) ACIS_GeometricAtoms_method_SPApar_pos_v_getter, (setter) ACIS_GeometricAtoms_method_SPApar_pos_v_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPApar_pos[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPApar_pos[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPApar_pos = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPApar_pos), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPApar_pos, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_pos, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_pos, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPApar_pos, /* tp_methods */ - ACIS_GeometricAtoms_members_SPApar_pos, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPApar_pos, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPApar_pos, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPApar_pos, /* tp_new */ - }; - - -/** - * SPApar_vec wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPApar_vec(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPApar_vec *self; - - self = (ACIS_GeometricAtoms_SPApar_vec *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPApar_vec(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self) -{ - double du = self->_acis_obj->du; double dv = self->_acis_obj->dv; - - char *_du = PyOS_double_to_string(du, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_du) - return PyErr_NoMemory(); - - char *_dv = PyOS_double_to_string(dv, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_dv) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPApar_vec object (%s, %s)", _du, _dv); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_vec_du_getter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->du); -} - -static int -ACIS_GeometricAtoms_method_SPApar_vec_du_setter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - self->_acis_obj->du = PyFloat_AsDouble(value); - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_vec_dv_getter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->dv); -} - -static int -ACIS_GeometricAtoms_method_SPApar_vec_dv_setter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - self->_acis_obj->dv = PyFloat_AsDouble(value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPApar_vec[] = - { - { (char *) "du", (getter) ACIS_GeometricAtoms_method_SPApar_vec_du_getter, (setter) ACIS_GeometricAtoms_method_SPApar_vec_du_setter, (char *) "value of the u parameter", NULL }, - { (char *) "dv", (getter) ACIS_GeometricAtoms_method_SPApar_vec_dv_getter, (setter) ACIS_GeometricAtoms_method_SPApar_vec_dv_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPApar_vec[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPApar_vec[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPApar_vec = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPApar_vec), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPApar_vec, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_vec, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_vec, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPApar_vec, /* tp_methods */ - ACIS_GeometricAtoms_members_SPApar_vec, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPApar_vec, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPApar_vec, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPApar_vec, /* tp_new */ - }; - -/** - * Python module definitions - */ - -static PyObject * -ACIS_GeometricAtoms_method_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_origin = NULL, *input_x_axis = NULL, *input_y_axis = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "new_origin", - (char *) "new_x_axis", - (char *) "new_y_axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_origin, &input_x_axis, &input_y_axis)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAposition(input_origin)) - { - PyErr_SetString(PyExc_TypeError, "First parameter (new_origin) must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_SPAunit_vector(input_x_axis)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (new_x_axis) must be a SPAunit_vector object"); - return NULL; - } - - if (!_ACIS_check_SPAunit_vector(input_y_axis)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (new_y_axis) must be a SPAunit_vector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAposition *&_new_origin = ((ACIS_GeometricAtoms_SPAposition *) input_origin)->_acis_obj; - SPAunit_vector *&_new_x_axis = ((ACIS_GeometricAtoms_SPAunit_vector *) input_x_axis)->_acis_obj; - SPAunit_vector *&_new_y_axis = ((ACIS_GeometricAtoms_SPAunit_vector *) input_y_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = coordinate_transf(*_new_origin, *_new_x_axis, *_new_y_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_make_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_affine = NULL, *input_translation = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "affine", - (char *) "translation", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_affine, &input_translation)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAmatrix(input_affine)) - { - PyErr_SetString(PyExc_TypeError, "First parameter (affine) must be a SPAmatrix object"); - return NULL; - } - - if (!_ACIS_check_SPAvector(input_translation)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (translate) must be a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAmatrix *&_affine = ((ACIS_GeometricAtoms_SPAmatrix *) input_affine)->_acis_obj; - SPAvector *&_translation = ((ACIS_GeometricAtoms_SPAvector *) input_translation)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = make_transf(*_affine, *_translation); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_axis = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_axis)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAvector(input_axis)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_axis = ((ACIS_GeometricAtoms_SPAvector *) input_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = reflect_transf(*_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_axis = NULL; - double input_angle; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "angle", - (char *) "axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dO", kwlist, &input_angle, &input_axis)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAvector(input_axis)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_axis = ((ACIS_GeometricAtoms_SPAvector *) input_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = rotate_transf(input_angle, *_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL, *input_arg6 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "scale", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOOO", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5, &input_arg6)) - return NULL; - - SPAtransf retval; - - if (!PyFloat_Check(input_arg1)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg1 = PyFloat_AsDouble(input_arg1); - - if (input_arg2 != NULL || input_arg3 != NULL) - { - if (!PyFloat_Check(input_arg2) && !PyFloat_Check(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg2 = PyFloat_AsDouble(input_arg2); - double _arg3 = PyFloat_AsDouble(input_arg3); - - if (input_arg4 != NULL || input_arg5 != NULL || input_arg6 != NULL) - { - if (!PyFloat_Check(input_arg4) && !PyFloat_Check(input_arg5) && !PyFloat_Check(input_arg5)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg4 = PyFloat_AsDouble(input_arg4); - double _arg5 = PyFloat_AsDouble(input_arg5); - double _arg6 = PyFloat_AsDouble(input_arg5); - - retval = scale_transf(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6); - } - else - { - retval = scale_transf(_arg1, _arg2, _arg3); - } - } - else - { - retval = scale_transf(_arg1); - } - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double _shear_xy, _shear_xz, _shear_yz; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "shearxy", - (char *) "shearxz", - (char *) "shearyz", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddd", kwlist, &_shear_xy, &_shear_xz, &_shear_yz)) - return NULL; - - // Execute ACIS function - SPAtransf retval = shear_transf(_shear_xy, _shear_xz, _shear_yz); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_disp = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "disp", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_disp)) - return NULL; - - // "disp" must be a SPAvector object - if (!_ACIS_check_SPAvector(input_disp)) - { - PyErr_SetString(PyExc_TypeError, "Expecting SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_disp = ((ACIS_GeometricAtoms_SPAvector *) input_disp)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = translate_transf(*_disp); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_angle_between(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL, *input_z = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "z", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist, &input_v1, &input_v2, &input_z)) - return NULL; - - // Set return value - double _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - if (input_z != NULL) - { - if (!_ACIS_check_SPAvector(input_z)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_z = ((ACIS_GeometricAtoms_SPAunit_vector *) input_z)->_acis_obj; - - _retval = angle_between(*_v1, *_v2, *_z); - } - else - { - _retval = angle_between(*_v1, *_v2); - } - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_z != NULL) - { - if (!_ACIS_check_SPAunit_vector(input_z)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_z = ((ACIS_GeometricAtoms_SPAunit_vector *) input_z)->_acis_obj; - - _retval = angle_between(*_v1, *_v2, *_z); - } - else - { - _retval = angle_between(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return PyFloat object - return PyFloat_FromDouble(_retval); -} - -static PyObject * -ACIS_GeometricAtoms_method_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - double input_res = -1.0; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "res", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2) || !_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = antiparallel(*_v1, *_v2, input_res); - } - else - { - _retval = antiparallel(*_v1, *_v2); - } - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2) || !_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector or SPAvector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = antiparallel(*_v1, *_v2, input_res); - } - else - { - _retval = antiparallel(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - int input_same_dir = 0; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "same_dir", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i", kwlist, &input_v1, &input_v2, &input_same_dir)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - _retval = are_parallel(*_v1, *_v2, input_same_dir); - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - _retval = are_parallel(*_v1, *_v2, input_same_dir); - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_v1, &input_v2)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - _retval = are_perpendicular(*_v1, *_v2); - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - _retval = are_perpendicular(*_v1, *_v2); - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_biparallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - double input_res = -1.0; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "res", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = biparallel(*_v1, *_v2, input_res); - } - else - { - _retval = biparallel(*_v1, *_v2); - } - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = biparallel(*_v1, *_v2, input_res); - } - else - { - _retval = biparallel(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_ang; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ang", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) - return NULL; - - double _retval = degrees_to_radians(input_ang); - - // Return double - return PyFloat_FromDouble(_retval); -} - -static PyObject * -ACIS_GeometricAtoms_method_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_ang; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ang", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) - return NULL; - - double _retval = radians_to_degrees(input_ang); - - // Return double - return PyFloat_FromDouble(_retval); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resabs(PyObject *self) -{ - return PyFloat_FromDouble(get_resabs()); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resfit(PyObject *self) -{ - return PyFloat_FromDouble(get_resfit()); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resmch(PyObject *self) -{ - return PyFloat_FromDouble(get_resmch()); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resnor(PyObject *self) -{ - return PyFloat_FromDouble(get_resnor()); -} - -static PyObject * -ACIS_GeometricAtoms_method_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) - return NULL; - - if (!_ACIS_check_SPAposition(input_pt1) || !_ACIS_check_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); - return NULL; - } - - SPAposition *&_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; - SPAposition *&_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; - - // Return double - return PyFloat_FromDouble(distance_to_point(*_pt1, *_pt2)); -} - -static PyObject * -ACIS_GeometricAtoms_method_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) - return NULL; - - if (!_ACIS_check_SPAposition(input_pt1) || !_ACIS_check_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); - return NULL; - } - - SPAposition *&_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; - SPAposition *&_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; - - // Return double - return PyFloat_FromDouble(distance_to_point_squared(*_pt1, *_pt2)); -} - -static PyMethodDef - module_methods[] = - { - { "coordinate_transf", (PyCFunction) ACIS_GeometricAtoms_method_coordinate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a coordinate transformation" }, - { "make_transf", (PyCFunction) ACIS_GeometricAtoms_method_make_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation retrieving the needed information from the provided transformation matrix and the scaling vector" }, - { "reflect_transf", (PyCFunction) ACIS_GeometricAtoms_method_reflect_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a reflection through a plane, specified by its normal" }, - { "rotate_transf", (PyCFunction) ACIS_GeometricAtoms_method_rotate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a simple rotation by an angle about a given axis" }, - { "scale_transf", (PyCFunction) ACIS_GeometricAtoms_method_scale_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a scale transformation (uniform, non-uniform and shear)" }, - { "shear_transf", (PyCFunction) ACIS_GeometricAtoms_method_shear_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a shear transformation" }, - { "translate_transf", (PyCFunction) ACIS_GeometricAtoms_method_translate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a translation by a given vector" }, - { "angle_between", (PyCFunction) ACIS_GeometricAtoms_method_angle_between, METH_VARARGS | METH_KEYWORDS, "Calculates the angle between two vectors or unit vectors" }, - { "antiparallel", (PyCFunction) ACIS_GeometricAtoms_method_antiparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are anti-parallel" }, - { "are_parallel", (PyCFunction) ACIS_GeometricAtoms_method_are_parallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are parallel" }, - { "are_perpendicular", (PyCFunction) ACIS_GeometricAtoms_method_are_perpendicular, METH_VARARGS | METH_KEYWORDS, " Determines if two vectors or unit vectors are perpendicular" }, - { "biparallel", (PyCFunction) ACIS_GeometricAtoms_method_biparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are bi-parallel" }, - { "degrees_to_radians", (PyCFunction) ACIS_GeometricAtoms_method_degrees_to_radians, METH_VARARGS | METH_KEYWORDS, "Converts an angle from degrees to radians" }, - { "radians_to_degrees", (PyCFunction) ACIS_GeometricAtoms_method_radians_to_degrees, METH_VARARGS | METH_KEYWORDS, "Converts an angle from radians to degrees" }, - { "get_resabs", (PyCFunction) ACIS_GeometricAtoms_method_get_resabs, METH_NOARGS, "Gets the SPAresabs resolution" }, - { "get_resfit", (PyCFunction) ACIS_GeometricAtoms_method_get_resfit, METH_NOARGS, "Gets the SPAresfit resolution" }, - { "get_resmch", (PyCFunction) ACIS_GeometricAtoms_method_get_resmch, METH_NOARGS, "Gets the resmch resolution" }, - { "get_resnor", (PyCFunction) ACIS_GeometricAtoms_method_get_resnor, METH_NOARGS, "Gets the SPAresnor resolution" }, - { "distance_to_point", (PyCFunction) ACIS_GeometricAtoms_method_distance_to_point, METH_VARARGS | METH_KEYWORDS, "Determines the distance between two points" }, - { "distance_to_point_squared", (PyCFunction) ACIS_GeometricAtoms_method_distance_to_point_squared, METH_VARARGS | METH_KEYWORDS, "\tComputes the squared distance between two positions" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "GeometricAtoms"; -const char *module_documentation = "Contains 3D ACIS Modeler geometric atoms, e.g. SPAposition, SPApar_pos, etc."; - -static struct PyModuleDef - ACIS_GeometricAtoms_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_GeometricAtoms(void) -{ - PyObject *m; - m = PyModule_Create(&ACIS_GeometricAtoms_module); - if (m == NULL) - return NULL; - - // SPAposition - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAposition) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAposition); - PyModule_AddObject(m, "SPAposition", (PyObject *) &ACIS_GeometricAtoms_type_SPAposition); - - // SPAtransf - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAtransf) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAtransf); - PyModule_AddObject(m, "SPAtransf", (PyObject *) &ACIS_GeometricAtoms_type_SPAtransf); - - // SPAmatrix - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAmatrix) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAmatrix); - PyModule_AddObject(m, "SPAmatrix", (PyObject *) &ACIS_GeometricAtoms_type_SPAmatrix); - - // SPAvector - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAvector) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAvector); - PyModule_AddObject(m, "SPAvector", (PyObject *) &ACIS_GeometricAtoms_type_SPAvector); - - // SPAunit_vector - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAunit_vector) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAunit_vector); - PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &ACIS_GeometricAtoms_type_SPAunit_vector); - - // SPApar_pos - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPApar_pos) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPApar_pos); - PyModule_AddObject(m, "SPApar_pos", (PyObject *) &ACIS_GeometricAtoms_type_SPApar_pos); - - // SPApar_vec - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPApar_vec) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPApar_vec); - PyModule_AddObject(m, "SPApar_vec", (PyObject *) &ACIS_GeometricAtoms_type_SPApar_vec); - - return m; -} - -bool _ACIS_check_SPAposition(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAposition; -} - -PyObject *_ACIS_new_SPAposition() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAposition, NULL); -} - -bool _ACIS_check_SPAvector(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAvector; -} - -PyObject *_ACIS_new_SPAvector() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAvector, NULL); -} - -bool _ACIS_check_SPAunit_vector(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAunit_vector; -} - -PyObject *_ACIS_new_SPAunit_vector() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAunit_vector, NULL); -} - -bool _ACIS_check_SPAmatrix(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAmatrix; -} - -PyObject *_ACIS_new_SPAmatrix() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAmatrix, NULL); -} - -bool _ACIS_check_SPAtransf(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAtransf; -} - -PyObject *_ACIS_new_SPAtransf() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAtransf, NULL); -} - -bool _ACIS_check_SPApar_pos(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPApar_pos; -} - -PyObject *_ACIS_new_SPApar_pos() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPApar_pos, NULL); -} - -bool _ACIS_check_SPApar_vec(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPApar_vec; -} - -PyObject *_ACIS_new_SPApar_vec() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPApar_vec, NULL); -} diff --git a/src/acis_geometric_atoms.h b/src/acis_geometric_atoms.h deleted file mode 100644 index ce4ef8a..0000000 --- a/src/acis_geometric_atoms.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_GEOMETRIC_ATOMS_H -#define ACIS_GEOMETRIC_ATOMS_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "acis_geometric_atoms_export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Define SPAposition -typedef struct -{ - PyObject_HEAD - SPAposition *_acis_obj; -} ACIS_GeometricAtoms_SPAposition; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAposition(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAposition(PyObject *ob); - -// Define SPAvector -typedef struct -{ - PyObject_HEAD - SPAvector *_acis_obj; -} ACIS_GeometricAtoms_SPAvector; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAvector(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAvector(PyObject *ob); - -// Define SPAunit_vector -typedef struct -{ - PyObject_HEAD - SPAunit_vector *_acis_obj; -} ACIS_GeometricAtoms_SPAunit_vector; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAunit_vector(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAunit_vector(PyObject *ob); - -// Define SPAmatrix -typedef struct -{ - PyObject_HEAD - SPAmatrix *_acis_obj; -} ACIS_GeometricAtoms_SPAmatrix; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAmatrix(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAmatrix(PyObject *ob); - -// Define SPAtransf -typedef struct -{ - PyObject_HEAD - SPAtransf *_acis_obj; -} ACIS_GeometricAtoms_SPAtransf; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAtransf(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAtransf(PyObject *ob); - -// Define SPApar_pos -typedef struct -{ - PyObject_HEAD - SPApar_pos *_acis_obj; -} ACIS_GeometricAtoms_SPApar_pos; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPApar_pos(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPApar_pos(PyObject *ob); - -// Define SPApar_vec -typedef struct -{ - PyObject_HEAD - SPApar_vec *_acis_obj; -} ACIS_GeometricAtoms_SPApar_vec; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPApar_vec(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPApar_vec(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_GEOMETRIC_ATOMS_H diff --git a/src/acis_includes.h b/src/acis_includes.h new file mode 100644 index 0000000..f986116 --- /dev/null +++ b/src/acis_includes.h @@ -0,0 +1,36 @@ +#ifndef A3DPY_INCLUDES_H +#define A3DPY_INCLUDES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif // !A3DPY_INCLUDES_H diff --git a/src/acis_licensing.cpp b/src/acis_licensing.cpp deleted file mode 100644 index 486d06f..0000000 --- a/src/acis_licensing.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include - -#include -#include -#include - - -static PyObject * -ACIS_spa_unlock_products(PyObject *self, PyObject *arg) -{ - // Check if the input is a string - if (!PyUnicode_Check(arg)) - { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } - - // Convert PyObject to C-style string - const char *unlock_str = PyUnicode_AsUTF8(arg); - - // Call ACIS Licensing API - spa_unlock_result out = spa_unlock_products(unlock_str); - - // If license is good, then return True. Otherwise, return the licensing error message - if (SPA_UNLOCK_PASS == out.get_state()) - Py_RETURN_TRUE; - else - return PyUnicode_FromString(out.get_message_text()); -} - -static PyMethodDef - ACIS_Licensing_methods[] = - { - { "spa_unlock_products", (PyCFunction) ACIS_spa_unlock_products, METH_O, "Unlock the 3D ACIS Modeler using the license key" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_documentation = "Contains 3D ACIS Modeler licensing API related functions and classes"; - -static struct PyModuleDef - ACIS_Licensing_module = - { - PyModuleDef_HEAD_INIT, - "Licensing", // name of module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - ACIS_Licensing_methods - }; - -PyMODINIT_FUNC -PyInit_Licensing(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Licensing_module); - if (m == NULL) - return NULL; - - return m; -} diff --git a/src/acis_lists.cpp b/src/acis_lists.cpp deleted file mode 100644 index 7166971..0000000 --- a/src/acis_lists.cpp +++ /dev/null @@ -1,440 +0,0 @@ -#include "acis_lists.h" - - -/** - * 3D ACIS Modeler - ENTITY_LIST wrapper - */ - -static void -ACIS_Lists_dealloc_ENTITY_LIST(ACIS_Lists_ENTITY_LIST *self) -{ - // First, clear the contents of the ENTITY_LIST instance - self->_acis_obj->clear(); - - // Use ACIS_DELETE macro for ENTITY_LIST - ACIS_DELETE self->_acis_obj; - - // Delete the python object itself - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_Lists_new_ENTITY_LIST(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_Lists_ENTITY_LIST *self; - - self = (ACIS_Lists_ENTITY_LIST *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_Lists_init_ENTITY_LIST(ACIS_Lists_ENTITY_LIST *self) -{ - // ENTITY_LIST takes no arguments, so parsing is necessary - self->_acis_obj = ACIS_NEW ENTITY_LIST(); - return 0; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_init(ACIS_Lists_ENTITY_LIST *self) -{ - self->_acis_obj->init(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_clear(ACIS_Lists_ENTITY_LIST *self) -{ - self->_acis_obj->clear(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_add(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - int index = -1; - - if (!_ACIS_check_ENTITY(arg)) - { - if (!_ACIS_check_ENTITY_LIST(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY or ENTITY_LIST object"); - return NULL; - } - else - { - // This function returns void - self->_acis_obj->add(*((ACIS_Lists_ENTITY_LIST *) arg)->_acis_obj); - } - } - else - { - // This function returns the added ENTITY's index number - index = self->_acis_obj->add(((ACIS_Entity_ENTITY *) arg)->_acis_obj); - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - if (index != -1) - { - return PyLong_FromLong(index); - } - else - { - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_remove(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - int index = -1; - - if (!_ACIS_check_ENTITY(arg)) - { - if (!_ACIS_check_ENTITY_LIST(arg)) - { - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY, an ENTITY_LIST or an integer object"); - return NULL; - } - else - { - // This function returns the index number - index = self->_acis_obj->remove((int) PyLong_AsLong(arg)); - } - } - else - { - // This function returns void - self->_acis_obj->remove(*((ACIS_Lists_ENTITY_LIST *) arg)->_acis_obj); - } - } - else - { - // This function returns the removed ENTITY's index number - index = self->_acis_obj->remove(((ACIS_Entity_ENTITY *) arg)->_acis_obj); - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - if (index != -1) - { - return PyLong_FromLong(index); - } - else - { - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_count(ACIS_Lists_ENTITY_LIST *self) -{ - return PyLong_FromLong(self->_acis_obj->count()); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_iteration_count(ACIS_Lists_ENTITY_LIST *self) -{ - return PyLong_FromLong(self->_acis_obj->iteration_count()); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_reverse(ACIS_Lists_ENTITY_LIST *self) -{ - self->_acis_obj->reverse(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_lookup(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - if (!_ACIS_check_ENTITY(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY object"); - return NULL; - } - - int index = self->_acis_obj->lookup(((ACIS_Entity_ENTITY *) arg)->_acis_obj); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - return PyLong_FromLong(index); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_byte_count(ACIS_Lists_ENTITY_LIST *self) -{ - return PyLong_FromLong(self->_acis_obj->byte_count()); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_first(ACIS_Lists_ENTITY_LIST *self) -{ - ENTITY *_elem = self->_acis_obj->first(); - PyObject *retobj = __convert_entity(_elem); - return retobj; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_next(ACIS_Lists_ENTITY_LIST *self) -{ - PyObject *retobj; - ENTITY *_elem = self->_acis_obj->next(); - - if (_elem) - { - retobj = __convert_entity(_elem); - } - else - { - // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - - return retobj; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_next_from(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an integer object"); - return NULL; - } - - Py_INCREF(arg); - int _from_index = (int) PyLong_AsLong(arg); - Py_DECREF(arg); - - PyObject *retobj; - ENTITY *_elem = self->_acis_obj->next_from(_from_index); - - if (_elem) - { - retobj = __convert_entity(_elem); - } - else - { - // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - - return retobj; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_array(ACIS_Lists_ENTITY_LIST *self) -{ - /* This function will create a Python generator/iterator */ - - // Reference increment is necessary, otherwise this ENTITY_LIST will be garbage collected - Py_INCREF(self); - - // Iterator/Generator creation functions always return self! - return (PyObject *) self; -} - -static PyObject * -ACIS_Lists_iter_ENTITY_LIST(PyObject *self) -{ - /* Must have the same signature as PyObject_GetIter() */ - - // Move the ENTITY_LIST pointer to the beginning - ACIS_Lists_method_ENTITY_LIST_init((ACIS_Lists_ENTITY_LIST *) self); - - Py_INCREF(self); - return self; -} - -static PyObject * -ACIS_Lists_iter_next_ENTITY_LIST(PyObject *self) -{ - /* Must have the same signature as PyIter_Next() */ - - // Convert the input argument to a ENTITY_LIST object - ACIS_Lists_ENTITY_LIST *_ent_list = (ACIS_Lists_ENTITY_LIST *) self; - - // Return the next element - return ACIS_Lists_method_ENTITY_LIST_next(_ent_list); -} - -static PyGetSetDef - ACIS_Lists_getseters_ENTITY_LIST[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Lists_members_ENTITY_LIST[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Lists_methods_ENTITY_LIST[] = - { - { "add", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_add, METH_O, "Adds an entity or entities to the list" }, - { "remove", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_remove, METH_O, "Removes an entity or entities from the list" }, - { "count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, - { "iteration_count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, - { "init", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_init, METH_NOARGS, "Adds an entity or entities to the list" }, - { "lookup", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_lookup, METH_O, "Adds an entity or entities to the list" }, - { "reverse", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_reverse, METH_NOARGS, "Adds an entity or entities to the list" }, - { "byte_count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, - { "first", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, - { "next", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_next, METH_NOARGS, "Returns the next undeleted (live) entry" }, - { "next_from", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, - { "array", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Lists_type_ENTITY_LIST = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.ENTITY_LIST", /* tp_name */ - sizeof(ACIS_Lists_ENTITY_LIST), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Lists_dealloc_ENTITY_LIST, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS ENTITY_LIST class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) ACIS_Lists_iter_ENTITY_LIST, /* tp_iter */ - (iternextfunc) ACIS_Lists_iter_next_ENTITY_LIST, /* tp_iternext */ - ACIS_Lists_methods_ENTITY_LIST, /* tp_methods */ - ACIS_Lists_members_ENTITY_LIST, /* tp_members */ - ACIS_Lists_getseters_ENTITY_LIST, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Lists_init_ENTITY_LIST, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Lists_new_ENTITY_LIST, /* tp_new */ - }; - - -/* - * Python Module Definitions - */ - -// Module documentation can be accessible via __doc__ -const char *module_name = "Lists"; -const char *module_documentation = "Contains 3D ACIS Modeler lists and containers, such as ENTITY_LIST"; - -static PyModuleDef - ACIS_Lists_module = - { - PyModuleDef_HEAD_INIT, - module_name, - module_documentation, - -1, - NULL, NULL, NULL, NULL, NULL - }; - -PyMODINIT_FUNC -PyInit_Lists(void) -{ - // Create a Python module, ACIS.Objects - PyObject *m; - m = PyModule_Create(&ACIS_Lists_module); - if (m == NULL) - return NULL; - - // Initialize ACIS ENTITY_LIST class as a Python type - if (PyType_Ready(&ACIS_Lists_type_ENTITY_LIST) < 0) - return NULL; - - // Increase the reference counter of the ENTITY_LIST type - Py_INCREF(&ACIS_Lists_type_ENTITY_LIST); - - // Add ENTITY_LIST type to the Objects module - PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &ACIS_Lists_type_ENTITY_LIST); - - // Return the module and all included objects - return m; -} - -PyObject *_ACIS_new_ENTITY_LIST() -{ - return PyObject_CallObject((PyObject *) &ACIS_Lists_type_ENTITY_LIST, NULL); -} - -bool _ACIS_check_ENTITY_LIST(PyObject *ob) -{ - if (Py_TYPE(ob) == &ACIS_Lists_type_ENTITY_LIST) - return true; - else - return false; -} - -PyObject *__convert_entity(ENTITY *ent) -{ - // Find the type name of the entity - const char *_type_name = ent->type_name(); - - // We could use a hashing function here... - PyObject *_retobj; - if (strcmp("body", _type_name) == 0) - { - _retobj = _ACIS_new_BODY(); - _ACIS_set_entity(_retobj, ent); - } - else if (strcmp("face", _type_name) == 0) - { - _retobj = _ACIS_new_FACE(); - _ACIS_set_entity(_retobj, ent); - } - else if (strcmp("surface", _type_name) == 0) - { - _retobj = _ACIS_new_SURFACE(); - _ACIS_set_entity(_retobj, ent); - } - - return _retobj; -} diff --git a/src/acis_lists.h b/src/acis_lists.h deleted file mode 100644 index 1838e70..0000000 --- a/src/acis_lists.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_LISTS_H -#define ACIS_LISTS_H - -#include -#include - -#include - -#include "acis_entity.h" - -#include "acis_lists_export.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -// Define ENTITY_LIST -typedef struct -{ - PyObject_HEAD - ENTITY_LIST *_acis_obj; -} ACIS_Lists_ENTITY_LIST; - -PyObject ACIS_LISTS_EXPORT *_ACIS_new_ENTITY_LIST(); - -bool ACIS_LISTS_EXPORT _ACIS_check_ENTITY_LIST(PyObject *ob); - -PyObject ACIS_LISTS_EXPORT *__convert_entity(ENTITY *ent); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_LISTS_H diff --git a/src/acis_modeler.cpp b/src/acis_modeler.cpp index a93f873..3d3d0f0 100644 --- a/src/acis_modeler.cpp +++ b/src/acis_modeler.cpp @@ -1,705 +1,313 @@ #include "acis_modeler.h" -bool disabled_acis_freelisting = false; - -static PyObject * -ACIS_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_n = 0; - int input_freelisting = 1; +const char *module_name = "Modeler"; +const char *module_documentation = "3D ACIS Modeler"; - // List of keyword arguments that this function can take - static char *kwlist[] = +static PyMethodDef + module_methods[] = { - (char *) "n", - (char *) "freelisting", - NULL + { "spa_unlock_products", (PyCFunction) a3dp_spa_unlock_products, METH_O, "Unlock the 3D ACIS Modeler using the license key" }, + { "api_start_modeller", (PyCFunction) a3dp_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Starts the 3D ACIS Modeler" }, + { "api_stop_modeller", (PyCFunction) a3dp_api_stop_modeller, METH_NOARGS, "Stops the 3D ACIS Modeler" }, + { "is_modeler_started", (PyCFunction) a3dp_is_modeler_started, METH_NOARGS, "Checks if the 3D ACIS Modeler started" }, + { "api_start_modeler", (PyCFunction) a3dp_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Alternative way to call api_start_modeller()" }, + { "api_stop_modeler", (PyCFunction) a3dp_api_stop_modeller, METH_NOARGS, "Alternative way to call api_stop_modeller()" }, + { "api_save_entity_list", (PyCFunction) a3dp_api_save_entity_list, METH_VARARGS | METH_KEYWORDS, "Writes entities to a file in text or binary format" }, + { "api_set_file_info", (PyCFunction) a3dp_api_set_file_info, METH_VARARGS | METH_KEYWORDS, "Sets required header info to be written to ACIS save files" }, + { "api_get_file_info", (PyCFunction) a3dp_api_get_file_info, METH_O | METH_KEYWORDS, "Gets header info from the last restored file" }, + { "api_save_version", (PyCFunction) a3dp_api_save_version, METH_VARARGS | METH_KEYWORDS, "Sets the save file format" }, + { "api_set_dbl_option", (PyCFunction) a3dp_api_set_dbl_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given double" }, + { "api_set_int_option", (PyCFunction) a3dp_api_set_int_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given integer" }, + { "api_set_str_option", (PyCFunction) a3dp_api_set_str_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given string" }, + { "api_solid_block", (PyCFunction) a3dp_api_solid_block, METH_VARARGS | METH_KEYWORDS, "Creates a solid block given two positions on a diagonal of the block" }, + { "api_make_cuboid", (PyCFunction) a3dp_api_make_cuboid, METH_VARARGS | METH_KEYWORDS, "Creates cuboid of given width (x), depth (y) and height (z)" }, + { "api_make_frustum", (PyCFunction) a3dp_api_make_frustum, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical cone or cylinder of given height and radii" }, + { "api_make_prism", (PyCFunction) a3dp_api_make_prism, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical prism of given height, radii, and number of sides" }, + { "api_make_pyramid", (PyCFunction) a3dp_api_make_pyramid, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical pyramid of given height, radii, and number of sides" }, + { "api_make_sphere", (PyCFunction) a3dp_api_make_sphere, METH_VARARGS | METH_KEYWORDS, "Creates a sphere of given radius, centered at the origin" }, + { "api_make_torus", (PyCFunction) a3dp_api_make_torus, METH_VARARGS | METH_KEYWORDS, "Creates a torus of given major and minor radii centered at the origin" }, + { "api_apply_transf", (PyCFunction) a3dp_api_apply_transf, METH_VARARGS | METH_KEYWORDS, "Changes the transform entity attached to a body" }, + { "api_remove_transf", (PyCFunction) a3dp_api_remove_transf, METH_VARARGS | METH_KEYWORDS, "Removes (discards) the transformation of a body" }, + { "api_sheet_from_ff", (PyCFunction) a3dp_api_sheet_from_ff, METH_VARARGS | METH_KEYWORDS, "Creates a sheet body as a copy of a face" }, + { "api_unite", (PyCFunction) a3dp_api_unite, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean unite operation" }, + { "api_intersect", (PyCFunction) a3dp_api_intersect, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean intersect operation on two bodies" }, + { "api_subtract", (PyCFunction) a3dp_api_subtract, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean subtract operation" }, + { "api_imprint", (PyCFunction) a3dp_api_imprint, METH_VARARGS | METH_KEYWORDS, "Intersects two bodies and imprints the intersection graph on both bodies" }, + { "api_boolean_chop_body", (PyCFunction) a3dp_api_boolean_chop_body, METH_VARARGS | METH_KEYWORDS, "Executes simultaneous Boolean intersect and subtract operations on two bodies" }, + { "api_make_sweep_path", (PyCFunction) a3dp_api_make_sweep_path, METH_VARARGS | METH_KEYWORDS, "Constructs a path useful for creating a swept surface" }, + { "api_sweep_with_options", (PyCFunction) a3dp_api_sweep_with_options, METH_VARARGS | METH_KEYWORDS, "Sweeps the given profile along an edge, a distance, a vector or an axis" }, + { "get_owner_transf", (PyCFunction) a3dp_get_owner_transf, METH_VARARGS | METH_KEYWORDS, "Gets a copy of the SPAtransf from the owner of an ENTITY" }, + { "api_get_faces", (PyCFunction) a3dp_api_get_faces, METH_VARARGS | METH_KEYWORDS, "Gets all faces related to an entity" }, + { "api_get_edges", (PyCFunction) a3dp_api_get_edges, METH_VARARGS | METH_KEYWORDS, "Gets all the edges related to an entity" }, + { "coordinate_transf", (PyCFunction) a3dp_coordinate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a coordinate transformation" }, + { "make_transf", (PyCFunction) a3dp_make_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation retrieving the needed information from the provided transformation matrix and the scaling vector" }, + { "reflect_transf", (PyCFunction) a3dp_reflect_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a reflection through a plane, specified by its normal" }, + { "rotate_transf", (PyCFunction) a3dp_rotate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a simple rotation by an angle about a given axis" }, + { "scale_transf", (PyCFunction) a3dp_scale_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a scale transformation (uniform, non-uniform and shear)" }, + { "shear_transf", (PyCFunction) a3dp_shear_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a shear transformation" }, + { "translate_transf", (PyCFunction) a3dp_translate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a translation by a given vector" }, + { "angle_between", (PyCFunction) a3dp_angle_between, METH_VARARGS | METH_KEYWORDS, "Calculates the angle between two vectors or unit vectors" }, + { "antiparallel", (PyCFunction) a3dp_antiparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are anti-parallel" }, + { "are_parallel", (PyCFunction) a3dp_are_parallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are parallel" }, + { "are_perpendicular", (PyCFunction) a3dp_are_perpendicular, METH_VARARGS | METH_KEYWORDS, " Determines if two vectors or unit vectors are perpendicular" }, + { "biparallel", (PyCFunction) a3dp_biparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are bi-parallel" }, + { "degrees_to_radians", (PyCFunction) a3dp_degrees_to_radians, METH_VARARGS | METH_KEYWORDS, "Converts an angle from degrees to radians" }, + { "radians_to_degrees", (PyCFunction) a3dp_radians_to_degrees, METH_VARARGS | METH_KEYWORDS, "Converts an angle from radians to degrees" }, + { "get_resabs", (PyCFunction) a3dp_get_resabs, METH_NOARGS, "Gets the SPAresabs resolution" }, + { "get_resfit", (PyCFunction) a3dp_get_resfit, METH_NOARGS, "Gets the SPAresfit resolution" }, + { "get_resmch", (PyCFunction) a3dp_get_resmch, METH_NOARGS, "Gets the resmch resolution" }, + { "get_resnor", (PyCFunction) a3dp_get_resnor, METH_NOARGS, "Gets the SPAresnor resolution" }, + { "distance_to_point", (PyCFunction) a3dp_distance_to_point, METH_VARARGS | METH_KEYWORDS, "Determines the distance between two points" }, + { "distance_to_point_squared", (PyCFunction) a3dp_distance_to_point_squared, METH_VARARGS | METH_KEYWORDS, "\tComputes the squared distance between two positions" }, + { NULL, NULL, 0, NULL } }; - // Try to parse input arguments and/or keywords - // api_start_modeller does not utilize the "n" argument, but following the implementation but make it optional - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist, &input_n, &input_freelisting)) - return NULL; - - // Disable ACIS freelisting facility if freelisting=False - if (!input_freelisting) +struct PyModuleDef + a3dp_module = { - // Display a warning message - PyErr_WarnEx(PyExc_Warning, "Disabling ACIS freelisting...", 0); - // Disable ACIS freelisting - base_configuration base_config; - base_config.enable_freelists = FALSE; - base_config.raw_allocator = malloc; - base_config.raw_destructor = free; - initialize_base(&base_config); - // Set the global variable for terminate_nase - disabled_acis_freelisting = true; - } - - // Call ACIS API and check outcome - outcome result; - result = api_start_modeller(input_n); - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} + PyModuleDef_HEAD_INIT, + module_name, // name of the module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + module_methods + }; -static PyObject * -ACIS_api_stop_modeller(PyObject *self) +PyMODINIT_FUNC +PyInit_Modeler(void) { - // Call ACIS API and check outcome - outcome result; - result = api_stop_modeller(); - - // If ACIS freelisting disabled, we need to call terminate_base() - if (disabled_acis_freelisting) - { - // Display a warning message - PyErr_WarnEx(PyExc_Warning, "Terminating ACIS...", 0); - terminate_base(); - } + PyObject *m; - // Check outcome - if (!check_outcome(result)) + m = PyModule_Create(&a3dp_module); + if (m == NULL) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_is_modeler_started(PyObject *self) -{ - // Initialize variables - logical check_modeler; - - // Call ACIS API - check_modeler = is_modeler_started(); - - // Return Python value - if (check_modeler) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} -static PyObject * -ACIS_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - double input_value; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sd", kwlist, &input_name, &input_value)) + // SPAposition + if (PyType_Ready(&a3dp_type_SPAposition) < 0) return NULL; + Py_INCREF(&a3dp_type_SPAposition); + PyModule_AddObject(m, "SPAposition", (PyObject *) &a3dp_type_SPAposition); - API_BEGIN - - result = api_set_dbl_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) + // SPAtransf + if (PyType_Ready(&a3dp_type_SPAtransf) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - int input_value; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; + Py_INCREF(&a3dp_type_SPAtransf); + PyModule_AddObject(m, "SPAtransf", (PyObject *) &a3dp_type_SPAtransf); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si", kwlist, &input_name, &input_value)) + // SPAmatrix + if (PyType_Ready(&a3dp_type_SPAmatrix) < 0) return NULL; + Py_INCREF(&a3dp_type_SPAmatrix); + PyModule_AddObject(m, "SPAmatrix", (PyObject *) &a3dp_type_SPAmatrix); - API_BEGIN - - result = api_set_int_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) + // SPAvector + if (PyType_Ready(&a3dp_type_SPAvector) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - const char *input_value = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; + Py_INCREF(&a3dp_type_SPAvector); + PyModule_AddObject(m, "SPAvector", (PyObject *) &a3dp_type_SPAvector); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &input_name, &input_value)) + // SPAunit_vector + if (PyType_Ready(&a3dp_type_SPAunitvector) < 0) return NULL; + Py_INCREF(&a3dp_type_SPAunitvector); + PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &a3dp_type_SPAunitvector); - API_BEGIN - - result = api_set_str_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) + // SPApar_pos + if (PyType_Ready(&a3dp_type_SPAparpos) < 0) return NULL; - else - Py_RETURN_NONE; -} + Py_INCREF(&a3dp_type_SPAparpos); + PyModule_AddObject(m, "SPApar_pos", (PyObject *) &a3dp_type_SPAparpos); -static PyObject * -ACIS_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL, *input_block = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - (char *) "block", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_pt1, &input_pt2, &input_block)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_SPAposition(input_pt1)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_block)) - { - PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + // SPApar_vec + if (PyType_Ready(&a3dp_type_SPAparvec) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - SPAposition *_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; - SPAposition *_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; - BODY *&_block = (BODY *&) ((ACIS_Entity_BODY *) input_block)->base_obj._acis_obj; + Py_INCREF(&a3dp_type_SPAparvec); + PyModule_AddObject(m, "SPApar_vec", (PyObject *) &a3dp_type_SPAparvec); - // Call ACIS API - result = api_solid_block(*_pt1, *_pt2, _block); - - API_END - - // Check outcome - if (!check_outcome(result)) + if (PyType_Ready(&a3dp_type_FileInfo) < 0) return NULL; - else - Py_RETURN_NONE; -} -static PyObject * -ACIS_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_x, input_y, input_z; - PyObject *input_body = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - (char *) "body", - NULL - }; + Py_INCREF(&a3dp_type_FileInfo); + PyModule_AddObject(m, "FileInfo", (PyObject *) &a3dp_type_FileInfo); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddO", kwlist, &input_x, &input_y, &input_z, &input_body)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_body)) + // Create a dictionary object for NDBOOL_KEEP enum + PyObject *_ndbk_dict; + _ndbk_dict = PyDict_New(); + if (_ndbk_dict != NULL) { - PyErr_SetString(PyExc_TypeError, "The fourth argument must be a BODY object"); - return NULL; + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_NEITHER", PyLong_FromLong(0L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_TOOL", PyLong_FromLong(1L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BLANK", PyLong_FromLong(2L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BOTH", PyLong_FromLong(3L)); } - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_body = (BODY *&) ((ACIS_Entity_BODY *) input_body)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_cuboid(input_x, input_y, input_z, _body); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2, input_top; - PyObject *input_frust = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "top", - (char *) "frust", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_frust)) + // NDBOOL_KEEP + a3dp_type_NDBOOLKEEP.tp_dict = _ndbk_dict; + if (PyType_Ready(&a3dp_type_NDBOOLKEEP) < 0) return NULL; + Py_INCREF(&a3dp_type_NDBOOLKEEP); + PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &a3dp_type_NDBOOLKEEP); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_frust)) + // Create a dictionary object for sweep_bool_type enum + PyObject *_sbt_dict; + _sbt_dict = PyDict_New(); + if (_sbt_dict != NULL) { - PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); - return NULL; + PyDict_SetItemString(_sbt_dict, "UNITE", PyLong_FromLong(0L)); + PyDict_SetItemString(_sbt_dict, "INTERSECT", PyLong_FromLong(1L)); + PyDict_SetItemString(_sbt_dict, "SUBTRACT", PyLong_FromLong(2L)); + PyDict_SetItemString(_sbt_dict, "LIMIT", PyLong_FromLong(3L)); + PyDict_SetItemString(_sbt_dict, "KEEP_BOTH", PyLong_FromLong(4L)); } - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_frust = (BODY *&) ((ACIS_Entity_BODY *) input_frust)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_frustum(input_height, input_radius1, input_radius2, input_top, _frust); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2; - int input_nsides; - PyObject *input_prism = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "nsides", - (char *) "frust", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_nsides, &input_prism)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_prism)) - { - PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); + // sweep_bool_type + a3dp_type_sweepbooltype.tp_dict = _sbt_dict; + if (PyType_Ready(&a3dp_type_sweepbooltype) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_prism = (BODY *&) ((ACIS_Entity_BODY *) input_prism)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_prism(input_height, input_radius1, input_radius2, input_nsides, _prism); + Py_INCREF(&a3dp_type_sweepbooltype); + PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &a3dp_type_sweepbooltype); - API_END - - // Check outcome - if (!check_outcome(result)) + // sweep_options + if (PyType_Ready(&a3dp_type_sweep_options) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2, input_top; - int input_nsides; - PyObject *input_pyramid = NULL; + Py_INCREF(&a3dp_type_sweep_options); + PyModule_AddObject(m, "sweep_options", (PyObject *) &a3dp_type_sweep_options); - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "top", - (char *) "nsides", - (char *) "pyramid", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_nsides, &input_pyramid)) + // make_sweep_path_options + if (PyType_Ready(&a3dp_type_make_sweep_path_options) < 0) return NULL; + Py_INCREF(&a3dp_type_make_sweep_path_options); + PyModule_AddObject(m, "make_sweep_path_options", (PyObject *) &a3dp_type_make_sweep_path_options); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_pyramid)) - { - PyErr_SetString(PyExc_TypeError, "The sixth argument must be a BODY object"); + // Add ENTITY to the module + if (PyType_Ready(&a3dp_type_ENTITY) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_pyramid = (BODY *&) ((ACIS_Entity_BODY *) input_pyramid)->base_obj._acis_obj; + Py_INCREF(&a3dp_type_ENTITY); + PyModule_AddObject(m, "ENTITY", (PyObject *) &a3dp_type_ENTITY); - // Call ACIS API - result = api_make_pyramid(input_height, input_radius1, input_radius2, input_top, input_nsides, _pyramid); - - API_END - - // Check outcome - if (!check_outcome(result)) + // Add BODY to the module + a3dp_type_BODY.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_BODY) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_radius; - PyObject *input_sph = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "radius", - (char *) "sph", - NULL - }; + Py_INCREF(&a3dp_type_BODY); + PyModule_AddObject(m, "BODY", (PyObject *) &a3dp_type_BODY); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_radius, &input_sph)) + // Add FACE to the module + a3dp_type_FACE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_FACE) < 0) return NULL; + Py_INCREF(&a3dp_type_FACE); + PyModule_AddObject(m, "FACE", (PyObject *) &a3dp_type_FACE); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_sph)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a BODY object"); + // Add EDGE to the module + a3dp_type_EDGE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_EDGE) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_sph = (BODY *&) ((ACIS_Entity_BODY *) input_sph)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_sphere(input_radius, _sph); - - API_END + Py_INCREF(&a3dp_type_EDGE); + PyModule_AddObject(m, "EDGE", (PyObject *) &a3dp_type_EDGE); - // Check outcome - if (!check_outcome(result)) + // Add WIRE to the module + a3dp_type_WIRE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_WIRE) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_major_r, input_minor_r; - PyObject *input_tor = NULL; + Py_INCREF(&a3dp_type_WIRE); + PyModule_AddObject(m, "WIRE", (PyObject *) &a3dp_type_WIRE); - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "major_radius", - (char *) "minor_radius", - (char *) "tor", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_major_r, &input_minor_r, &input_tor)) + // Add LUMP to the module + a3dp_type_LUMP.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_LUMP) < 0) return NULL; + Py_INCREF(&a3dp_type_LUMP); + PyModule_AddObject(m, "LUMP", (PyObject *) &a3dp_type_LUMP); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tor)) - { - PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + // Add SHELL to the module + a3dp_type_SHELL.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SHELL) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tor = (BODY *&) ((ACIS_Entity_BODY *) input_tor)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_torus(input_major_r, input_minor_r, _tor); + Py_INCREF(&a3dp_type_SHELL); + PyModule_AddObject(m, "SHELL", (PyObject *) &a3dp_type_SHELL); - API_END - - // Check outcome - if (!check_outcome(result)) + // Add SUBSHELL to the module + a3dp_type_SUBSHELL.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SUBSHELL) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_entity = NULL, *input_trans = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "entity", - (char *) "trans", - NULL - }; + Py_INCREF(&a3dp_type_SUBSHELL); + PyModule_AddObject(m, "SUBSHELL", (PyObject *) &a3dp_type_SUBSHELL); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity, &input_trans)) + // Add COEDGE to the module + a3dp_type_COEDGE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_COEDGE) < 0) return NULL; + Py_INCREF(&a3dp_type_COEDGE); + PyModule_AddObject(m, "COEDGE", (PyObject *) &a3dp_type_COEDGE); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_entity)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + // Add LOOP to the module + a3dp_type_LOOP.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_LOOP) < 0) return NULL; - } + Py_INCREF(&a3dp_type_LOOP); + PyModule_AddObject(m, "LOOP", (PyObject *) &a3dp_type_LOOP); - if (!_ACIS_check_SPAtransf(input_trans)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAtransf object"); + // Add VERTEX to the module + a3dp_type_VERTEX.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_VERTEX) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - ENTITY *&_entity = ((ACIS_Entity_BODY *) input_entity)->base_obj._acis_obj; - SPAtransf *&_trans = ((ACIS_GeometricAtoms_SPAtransf *) input_trans)->_acis_obj; - - // Call ACIS API - result = api_apply_transf(_entity, *_trans); + Py_INCREF(&a3dp_type_VERTEX); + PyModule_AddObject(m, "VERTEX", (PyObject *) &a3dp_type_VERTEX); - API_END - - // Check outcome - if (!check_outcome(result)) + // Add SURFACE to the module + a3dp_type_SURFACE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SURFACE) < 0) return NULL; - else - Py_RETURN_NONE; -} + Py_INCREF(&a3dp_type_SURFACE); + PyModule_AddObject(m, "SURFACE", (PyObject *) &a3dp_type_SURFACE); -static PyObject * -ACIS_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_entity = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "entity", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity)) + // Add CONE to the module + a3dp_type_CONE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_CONE) < 0) return NULL; + Py_INCREF(&a3dp_type_CONE); + PyModule_AddObject(m, "CONE", (PyObject *) &a3dp_type_CONE); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_entity)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + // Add PLANE to the module + a3dp_type_PLANE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_PLANE) < 0) return NULL; - } - - API_BEGIN + Py_INCREF(&a3dp_type_PLANE); + PyModule_AddObject(m, "PLANE", (PyObject *) &a3dp_type_PLANE); - // Convert PyObject to ACIS objects - ENTITY *&_entity = ((ACIS_Entity_BODY *) input_entity)->base_obj._acis_obj; - - // Call ACIS API - result = api_remove_transf(_entity); - - API_END - - // Check outcome - if (!check_outcome(result)) + // Add SPHERE to the module + a3dp_type_SPHERE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SPHERE) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_faces = NULL, *input_body = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "faces", - (char *) "body", - NULL - }; + Py_INCREF(&a3dp_type_SPHERE); + PyModule_AddObject(m, "SPHERE", (PyObject *) &a3dp_type_SPHERE); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_faces, &input_body)) + // Add SPLINE to the module + a3dp_type_SPLINE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SPLINE) < 0) return NULL; + Py_INCREF(&a3dp_type_SPLINE); + PyModule_AddObject(m, "SPLINE", (PyObject *) &a3dp_type_SPLINE); - // First argument must be a tuple of faces - PyObject *seq = PySequence_Fast(input_faces, "First argument must be a sequence of FACE objects"); - - // ACIS API has a limitation in api_sheet_from_ff function: As of version R2017, it can handle only 1 face - Py_ssize_t face_array_size = PySequence_Fast_GET_SIZE(seq); - if (face_array_size <= 0) - { - PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); - Py_DECREF(seq); + // Add TORUS to the module + a3dp_type_TORUS.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_TORUS) < 0) return NULL; - } - else if (face_array_size > 1) - { - PyErr_WarnEx(PyExc_Warning, "ACIS API does not support generation of sheet bodies from multiple faces.", 0); - } - - PyObject *faceobj = PySequence_Fast_GET_ITEM(seq, 0); - - API_BEGIN - - FACE *&_face = (FACE *&) ((ACIS_Entity_FACE *) faceobj)->base_obj._acis_obj; - - FACE *_faces[1]; - _faces[0] = _face; - - BODY *&_body = (BODY *&) ((ACIS_Entity_BODY *) input_body)->base_obj._acis_obj; - - result = api_sheet_from_ff(1, _faces, _body); - - API_END + Py_INCREF(&a3dp_type_TORUS); + PyModule_AddObject(m, "TORUS", (PyObject *) &a3dp_type_TORUS); - // PySequence_Fast generates a new reference - Py_DECREF(seq); - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error + // Add surface to the module + if (PyType_Ready(&a3dp_type_surface) < 0) return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - - - -static PyMethodDef - module_methods[] = - { - { "api_start_modeller", (PyCFunction) ACIS_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Starts the 3D ACIS Modeler" }, - { "api_stop_modeller", (PyCFunction) ACIS_api_stop_modeller, METH_NOARGS, "Stops the 3D ACIS Modeler" }, - { "is_modeler_started", (PyCFunction) ACIS_is_modeler_started, METH_NOARGS, "Checks if the 3D ACIS Modeler started" }, - { "api_start_modeler", (PyCFunction) ACIS_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Alternative way to call api_start_modeller()" }, - { "api_stop_modeler", (PyCFunction) ACIS_api_stop_modeller, METH_NOARGS, "Alternative way to call api_stop_modeller()" }, - { "api_set_dbl_option", (PyCFunction) ACIS_api_set_dbl_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given double" }, - { "api_set_int_option", (PyCFunction) ACIS_api_set_int_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given integer" }, - { "api_set_str_option", (PyCFunction) ACIS_api_set_str_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given string" }, - { "api_solid_block", (PyCFunction) ACIS_api_solid_block, METH_VARARGS | METH_KEYWORDS, "Creates a solid block given two positions on a diagonal of the block" }, - { "api_make_cuboid", (PyCFunction) ACIS_api_make_cuboid, METH_VARARGS | METH_KEYWORDS, "Creates cuboid of given width (x), depth (y) and height (z)" }, - { "api_make_frustum", (PyCFunction) ACIS_api_make_frustum, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical cone or cylinder of given height and radii" }, - { "api_make_prism", (PyCFunction) ACIS_api_make_prism, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical prism of given height, radii, and number of sides" }, - { "api_make_pyramid", (PyCFunction) ACIS_api_make_pyramid, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical pyramid of given height, radii, and number of sides" }, - { "api_make_sphere", (PyCFunction) ACIS_api_make_sphere, METH_VARARGS | METH_KEYWORDS, "Creates a sphere of given radius, centered at the origin" }, - { "api_make_torus", (PyCFunction) ACIS_api_make_torus, METH_VARARGS | METH_KEYWORDS, "Creates a torus of given major and minor radii centered at the origin" }, - { "api_apply_transf", (PyCFunction) ACIS_api_apply_transf, METH_VARARGS | METH_KEYWORDS, "Changes the transform entity attached to a body" }, - { "api_remove_transf", (PyCFunction) ACIS_api_remove_transf, METH_VARARGS | METH_KEYWORDS, "Removes (discards) the transformation of a body" }, - { "api_sheet_from_ff", (PyCFunction) ACIS_api_sheet_from_ff, METH_VARARGS | METH_KEYWORDS, "Creates a sheet body as a copy of a face" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Modeler"; -const char *module_documentation = "3D ACIS Modeler main modeling component"; + Py_INCREF(&a3dp_type_surface); + PyModule_AddObject(m, "surface", (PyObject *) &a3dp_type_surface); -static struct PyModuleDef - ACIS_Modeler_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Modeler(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Modeler_module); - if (m == NULL) + // Initialize ACIS ENTITY_LIST class as a Python type + if (PyType_Ready(&a3dp_type_ENTITYLIST) < 0) return NULL; + Py_INCREF(&a3dp_type_ENTITYLIST); + PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &a3dp_type_ENTITYLIST); return m; } diff --git a/src/acis_modeler.h b/src/acis_modeler.h index c2b07aa..a7028bf 100644 --- a/src/acis_modeler.h +++ b/src/acis_modeler.h @@ -9,19 +9,12 @@ * */ -#ifndef ACIS_MODELER_H -#define ACIS_MODELER_H +#ifndef A3DPY_MODELER_H +#define A3DPY_MODELER_H #include +#include -#include -#include -#include +#include "acis_api.h" -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "acis_saverestore.h" -#include "acis_lists.h" -#include "utilities.h" - -#endif //!ACIS_MODELER_H +#endif // !A3DPY_MODELER_H diff --git a/src/acis_operators.cpp b/src/acis_operators.cpp new file mode 100644 index 0000000..a6a4a87 --- /dev/null +++ b/src/acis_operators.cpp @@ -0,0 +1,802 @@ +#include "acis_operators.h" + + +PyObject * +a3dp_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_origin = NULL, *input_x_axis = NULL, *input_y_axis = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "new_origin", + (char *) "new_x_axis", + (char *) "new_y_axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_origin, &input_x_axis, &input_y_axis)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAposition(input_origin)) + { + PyErr_SetString(PyExc_TypeError, "First parameter (new_origin) must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_SPAunit_vector(input_x_axis)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (new_x_axis) must be a SPAunit_vector object"); + return NULL; + } + + if (!_PyCheck_SPAunit_vector(input_y_axis)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (new_y_axis) must be a SPAunit_vector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAposition *&_new_origin = ((a3dp_SPAposition *) input_origin)->_acis_obj; + SPAunit_vector *&_new_x_axis = ((a3dp_SPAunit_vector *) input_x_axis)->_acis_obj; + SPAunit_vector *&_new_y_axis = ((a3dp_SPAunit_vector *) input_y_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = coordinate_transf(*_new_origin, *_new_x_axis, *_new_y_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_make_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_affine = NULL, *input_translation = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "affine", + (char *) "translation", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_affine, &input_translation)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAmatrix(input_affine)) + { + PyErr_SetString(PyExc_TypeError, "First parameter (affine) must be a SPAmatrix object"); + return NULL; + } + + if (!_PyCheck_SPAvector(input_translation)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (translate) must be a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAmatrix *&_affine = ((a3dp_SPAmatrix *) input_affine)->_acis_obj; + SPAvector *&_translation = ((a3dp_SPAvector *) input_translation)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = make_transf(*_affine, *_translation); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_axis = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_axis)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAvector(input_axis)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_axis = ((a3dp_SPAvector *) input_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = reflect_transf(*_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_axis = NULL; + double input_angle; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "angle", + (char *) "axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dO", kwlist, &input_angle, &input_axis)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAvector(input_axis)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_axis = ((a3dp_SPAvector *) input_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = rotate_transf(input_angle, *_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL, *input_arg6 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "scale", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOOO", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5, &input_arg6)) + return NULL; + + SPAtransf retval; + + if (!PyFloat_Check(input_arg1)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg1 = PyFloat_AsDouble(input_arg1); + + if (input_arg2 != NULL || input_arg3 != NULL) + { + if (!PyFloat_Check(input_arg2) && !PyFloat_Check(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg2 = PyFloat_AsDouble(input_arg2); + double _arg3 = PyFloat_AsDouble(input_arg3); + + if (input_arg4 != NULL || input_arg5 != NULL || input_arg6 != NULL) + { + if (!PyFloat_Check(input_arg4) && !PyFloat_Check(input_arg5) && !PyFloat_Check(input_arg5)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg4 = PyFloat_AsDouble(input_arg4); + double _arg5 = PyFloat_AsDouble(input_arg5); + double _arg6 = PyFloat_AsDouble(input_arg5); + + retval = scale_transf(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6); + } + else + { + retval = scale_transf(_arg1, _arg2, _arg3); + } + } + else + { + retval = scale_transf(_arg1); + } + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double _shear_xy, _shear_xz, _shear_yz; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "shearxy", + (char *) "shearxz", + (char *) "shearyz", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddd", kwlist, &_shear_xy, &_shear_xz, &_shear_yz)) + return NULL; + + // Execute ACIS function + SPAtransf retval = shear_transf(_shear_xy, _shear_xz, _shear_yz); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_disp = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "disp", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_disp)) + return NULL; + + // "disp" must be a SPAvector object + if (!_PyCheck_SPAvector(input_disp)) + { + PyErr_SetString(PyExc_TypeError, "Expecting SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_disp = ((a3dp_SPAvector *) input_disp)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = translate_transf(*_disp); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_angle_between(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL, *input_z = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "z", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist, &input_v1, &input_v2, &input_z)) + return NULL; + + // Set return value + double _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + if (input_z != NULL) + { + if (!_PyCheck_SPAvector(input_z)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_z = ((a3dp_SPAunit_vector *) input_z)->_acis_obj; + + _retval = angle_between(*_v1, *_v2, *_z); + } + else + { + _retval = angle_between(*_v1, *_v2); + } + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_z != NULL) + { + if (!_PyCheck_SPAunit_vector(input_z)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_z = ((a3dp_SPAunit_vector *) input_z)->_acis_obj; + + _retval = angle_between(*_v1, *_v2, *_z); + } + else + { + _retval = angle_between(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return PyFloat object + return PyFloat_FromDouble(_retval); +} + +PyObject * +a3dp_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + double input_res = -1.0; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "res", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2) || !_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = antiparallel(*_v1, *_v2, input_res); + } + else + { + _retval = antiparallel(*_v1, *_v2); + } + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2) || !_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector or SPAvector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = antiparallel(*_v1, *_v2, input_res); + } + else + { + _retval = antiparallel(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + int input_same_dir = 0; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "same_dir", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i", kwlist, &input_v1, &input_v2, &input_same_dir)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + _retval = are_parallel(*_v1, *_v2, input_same_dir); + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + _retval = are_parallel(*_v1, *_v2, input_same_dir); + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_v1, &input_v2)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + _retval = are_perpendicular(*_v1, *_v2); + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + _retval = are_perpendicular(*_v1, *_v2); + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_biparallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + double input_res = -1.0; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "res", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = biparallel(*_v1, *_v2, input_res); + } + else + { + _retval = biparallel(*_v1, *_v2); + } + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = biparallel(*_v1, *_v2, input_res); + } + else + { + _retval = biparallel(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_ang; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ang", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) + return NULL; + + double _retval = degrees_to_radians(input_ang); + + // Return double + return PyFloat_FromDouble(_retval); +} + +PyObject * +a3dp_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_ang; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ang", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) + return NULL; + + double _retval = radians_to_degrees(input_ang); + + // Return double + return PyFloat_FromDouble(_retval); +} + +PyObject * +a3dp_get_resabs(PyObject *self) +{ + return PyFloat_FromDouble(get_resabs()); +} + +PyObject * +a3dp_get_resfit(PyObject *self) +{ + return PyFloat_FromDouble(get_resfit()); +} + +PyObject * +a3dp_get_resmch(PyObject *self) +{ + return PyFloat_FromDouble(get_resmch()); +} + +PyObject * +a3dp_get_resnor(PyObject *self) +{ + return PyFloat_FromDouble(get_resnor()); +} + +PyObject * +a3dp_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) + return NULL; + + if (!_PyCheck_SPAposition(input_pt1) || !_PyCheck_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); + return NULL; + } + + SPAposition *&_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; + SPAposition *&_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; + + // Return double + return PyFloat_FromDouble(distance_to_point(*_pt1, *_pt2)); +} + +PyObject * +a3dp_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) + return NULL; + + if (!_PyCheck_SPAposition(input_pt1) || !_PyCheck_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); + return NULL; + } + + SPAposition *&_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; + SPAposition *&_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; + + // Return double + return PyFloat_FromDouble(distance_to_point_squared(*_pt1, *_pt2)); +} diff --git a/src/acis_operators.h b/src/acis_operators.h new file mode 100644 index 0000000..52e2047 --- /dev/null +++ b/src/acis_operators.h @@ -0,0 +1,50 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_OPERATORS_H +#define A3DPY_OPERATORS_H + +#include +#include + +#include "acis_includes.h" +#include "acis_classes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +PyObject *a3dp_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_get_resnor(PyObject *self); +PyObject *a3dp_get_resmch(PyObject *self); +PyObject *a3dp_get_resfit(PyObject *self); +PyObject *a3dp_get_resabs(PyObject *self); +PyObject *a3dp_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_biparallel(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_angle_between(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_make_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_OPERATORS_H diff --git a/src/acis_query.cpp b/src/acis_query.cpp deleted file mode 100644 index 5a84d17..0000000 --- a/src/acis_query.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include "acis_query.h" - - -static PyObject * -ACIS_Query_method_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "entity", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_ent)) - return NULL; - - if (!_ACIS_check_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - // Get the ACIS object from the user input - ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = get_owner_transf(_ent); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL, *input_ent_list = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ent", - (char *) "face_list", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) - return NULL; - - if (!_ACIS_check_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - if (!_ACIS_check_ENTITY_LIST(input_ent_list)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - API_BEGIN - - // Get the ACIS objects from the user input - ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; - ENTITY_LIST *&_face_list = ((ACIS_Lists_ENTITY_LIST *) input_ent_list)->_acis_obj; - - // Call ACIS function - result = api_get_faces(_ent, *_face_list); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } - -} - -static PyObject * -ACIS_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL, *input_ent_list = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ent", - (char *) "edge_list", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) - return NULL; - - if (!_ACIS_check_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - if (!_ACIS_check_ENTITY_LIST(input_ent_list)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - API_BEGIN - - // Get the ACIS objects from the user input - ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; - ENTITY_LIST *&_edge_list = ((ACIS_Lists_ENTITY_LIST *) input_ent_list)->_acis_obj; - - // Call ACIS function - result = api_get_edges(_ent, *_edge_list); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } - -} - -static PyMethodDef - module_methods[] = - { - { "get_owner_transf", (PyCFunction) ACIS_Query_method_get_owner_transf, METH_VARARGS | METH_KEYWORDS, "Gets a copy of the SPAtransf from the owner of an ENTITY" }, - { "api_get_faces", (PyCFunction) ACIS_api_get_faces, METH_VARARGS | METH_KEYWORDS, "Gets all faces related to an entity" }, - { "api_get_edges", (PyCFunction) ACIS_api_get_edges, METH_VARARGS | METH_KEYWORDS, "Gets all the edges related to an entity" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Query"; -const char *module_documentation = "Contains 3D Modeler ACIS geometric and topological queries"; - -static struct PyModuleDef - ACIS_Query_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Query(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Query_module); - if (m == NULL) - return NULL; - - return m; -} diff --git a/src/acis_saverestore.cpp b/src/acis_saverestore.cpp deleted file mode 100644 index 6a3f1a9..0000000 --- a/src/acis_saverestore.cpp +++ /dev/null @@ -1,506 +0,0 @@ -#include "acis_saverestore.h" - - -/** - * Save & Restore - FileInfo wrapper - */ - -static void -ACIS_SaveRestore_dealloc_FileInfo(ACIS_SaveRestore_FileInfo *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object itself - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_SaveRestore_new_FileInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_SaveRestore_FileInfo *self; - - self = (ACIS_SaveRestore_FileInfo *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_SaveRestore_init_FileInfo(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - self->_acis_obj = ACIS_NEW FileInfo(); - return 0; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_acis_version(ACIS_SaveRestore_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->acis_version()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_date(ACIS_SaveRestore_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->date()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_file_version(ACIS_SaveRestore_FileInfo *self) -{ - return PyLong_FromLong((long) self->_acis_obj->file_version()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_product_id(ACIS_SaveRestore_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->product_id()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_reset(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->reset(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_reset_vars(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->reset_vars(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_restore(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->restore(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_save(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->save(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_set_masked(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - unsigned long input_field; - PyObject *input_file = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "field", - (char *) "file", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "lO", kwlist, &input_field, &input_file)) - return NULL; - - // Check if the user input is a FileInfo object - if (_ACIS_check_FileInfo(input_file)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - // Convert PyObject to ENTITY_LIST - FileInfo *_file = ((ACIS_SaveRestore_FileInfo *) input_file)->_acis_obj; - - // Execute ACIS function - self->_acis_obj->set_masked(input_field, *_file); - - // Return None - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_set_product_id(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - const char *input_id = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "id", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &input_id)) - return NULL; - - self->_acis_obj->set_product_id(input_id); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_set_units(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - double input_count; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "count", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_count)) - return NULL; - - self->_acis_obj->set_units(input_count); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_tol_abs(ACIS_SaveRestore_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->tol_abs()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_tol_nor(ACIS_SaveRestore_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->tol_nor()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_units(ACIS_SaveRestore_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->units()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_valid(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->valid(); - Py_RETURN_NONE; -} - -static PyMemberDef - ACIS_SaveRestore_members_FileInfo[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_SaveRestore_methods_FileInfo[] = - { - { "acis_version", (PyCFunction) ACIS_SaveRestore_method_FileInfo_acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, - { "date", (PyCFunction) ACIS_SaveRestore_method_FileInfo_date, METH_NOARGS, "Returns the date on the save file" }, - { "file_version", (PyCFunction) ACIS_SaveRestore_method_FileInfo_file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, - { "product_id", (PyCFunction) ACIS_SaveRestore_method_FileInfo_product_id, METH_NOARGS, "Returns the ID of the product" }, - { "reset", (PyCFunction) ACIS_SaveRestore_method_FileInfo_reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, - { "reset_vars", (PyCFunction) ACIS_SaveRestore_method_FileInfo_reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, - { "restore", (PyCFunction) ACIS_SaveRestore_method_FileInfo_restore, METH_NOARGS, "Restores the file information from a save file" }, - { "save", (PyCFunction) ACIS_SaveRestore_method_FileInfo_save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, - //{ "set_masked", (PyCFunction)ACIS_SaveRestore_method_FileInfo_set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, - { "set_product_id", (PyCFunction) ACIS_SaveRestore_method_FileInfo_set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, - { "set_units", (PyCFunction) ACIS_SaveRestore_method_FileInfo_set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, - { "tol_abs", (PyCFunction) ACIS_SaveRestore_method_FileInfo_tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, - { "tol_nor", (PyCFunction) ACIS_SaveRestore_method_FileInfo_tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, - { "units", (PyCFunction) ACIS_SaveRestore_method_FileInfo_units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, - { "valid", (PyCFunction) ACIS_SaveRestore_method_FileInfo_valid, METH_NOARGS, "Checks the values of the units and product id" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_SaveRestore_type_FileInfo = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FileInfo", /* tp_name */ - sizeof(ACIS_SaveRestore_FileInfo), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_SaveRestore_dealloc_FileInfo, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "FileInfo object contains additional required save file header information", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_SaveRestore_methods_FileInfo, /* tp_methods */ - ACIS_SaveRestore_members_FileInfo, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_SaveRestore_init_FileInfo, /* tp_init */ - 0, /* tp_alloc */ - ACIS_SaveRestore_new_FileInfo, /* tp_new */ - }; - - -/** - * Save & Restore Interface Functions - */ - -static PyObject * -ACIS_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs) -{ - // According to the documentation, Python 3 doesn't do good with FILE* objects, so we take "file name" as an input - const char *input_filename = NULL; - int input_savemode; - PyObject *input_entitylist = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "file_name", - (char *) "text_mode", - (char *) "entity_list_save", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO", kwlist, &input_filename, &input_savemode, &input_entitylist)) - return NULL; - - // Check if the input is an ENTITY_LIST - if (!_ACIS_check_ENTITY_LIST(input_entitylist)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - // Using the file name input as a string, create a file handle - FILE *_file_handle = fopen(input_filename, "w"); - - // Check if the file has been opened correctly - if (_file_handle == NULL) - { - PyErr_SetString(PyExc_IOError, "Cannot open file for writing!"); - return NULL; - } - - // Set file writing mode - logical _text_mode = (input_savemode == 0) ? FALSE : TRUE; - - API_NOP_BEGIN - - // Convert PyObject to ENTITY_LIST - ENTITY_LIST *_save_list = ((ACIS_Lists_ENTITY_LIST *) input_entitylist)->_acis_obj; - - - // Call ACIS API and check outcome - result = api_save_entity_list(_file_handle, _text_mode, *_save_list); - - API_NOP_END - - // Don't forget to close the file handle - fclose(_file_handle); - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_product_id = 0; - int input_units = 0; - PyObject *input_info = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "info", - (char *) "product_id", - (char *) "units", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii", kwlist, &input_info, &input_product_id, &input_units)) - return NULL; - - // Check if we have a FileInfo object - if (!_ACIS_check_FileInfo(input_info)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - // Set up the value of mask - bool _product_id = input_product_id != 0; - bool _units = input_units != 0; - - unsigned long _mask; - if (_product_id && !_units) - { - _mask = FileIdent; - } - else if (!_product_id && _units) - { - _mask = FileUnits; - } - else - { - _mask = FileUnits | FileIdent; - } - - API_BEGIN - - // Convert PyObject to FileInfo - FileInfo *_info = ((ACIS_SaveRestore_FileInfo *) input_info)->_acis_obj; - - result = api_set_file_info(_mask, *_info); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_info = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "info", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_info)) - return NULL; - - // Check if we have a FileInfo object - if (_ACIS_check_FileInfo(input_info)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to FileInfo - FileInfo *_info = ((ACIS_SaveRestore_FileInfo *) input_info)->_acis_obj; - - result = api_get_file_info(*_info); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_major_version, input_minor_version; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "major_version", - (char *) "minor_version", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_major_version, &input_minor_version)) - return NULL; - - API_BEGIN - - result = api_save_version(input_major_version, input_minor_version); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - - -static PyMethodDef - module_methods[] = - { - { "api_save_entity_list", (PyCFunction) ACIS_api_save_entity_list, METH_VARARGS | METH_KEYWORDS, "Writes entities to a file in text or binary format" }, - { "api_set_file_info", (PyCFunction) ACIS_api_set_file_info, METH_VARARGS | METH_KEYWORDS, "Sets required header info to be written to ACIS save files" }, - { "api_get_file_info", (PyCFunction) ACIS_api_get_file_info, METH_O | METH_KEYWORDS, "Gets header info from the last restored file" }, - { "api_save_version", (PyCFunction) ACIS_api_save_version, METH_VARARGS | METH_KEYWORDS, "Sets the save file format" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "SaveRestore"; -const char *module_documentation = "Contains 3D ACIS Modeler save & restore related classes and functions"; - -static PyModuleDef - ACIS_SaveRestore_module = - { - PyModuleDef_HEAD_INIT, - module_name, - module_documentation, - -1, - module_methods - }; - -PyMODINIT_FUNC -PyInit_SaveRestore(void) -{ - PyObject *m; - m = PyModule_Create(&ACIS_SaveRestore_module); - if (m == NULL) - return NULL; - - if (PyType_Ready(&ACIS_SaveRestore_type_FileInfo) < 0) - return NULL; - - Py_INCREF(&ACIS_SaveRestore_type_FileInfo); - PyModule_AddObject(m, "FileInfo", (PyObject *) &ACIS_SaveRestore_type_FileInfo); - - return m; -} - -bool _ACIS_check_FileInfo(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_SaveRestore_type_FileInfo; -} diff --git a/src/acis_saverestore.h b/src/acis_saverestore.h deleted file mode 100644 index a7b4505..0000000 --- a/src/acis_saverestore.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_SAVERESTORE_H -#define ACIS_SAVERESTORE_H - -#include -#include - -#include -#include - -#include "acis_lists.h" -#include "utilities.h" - -#include "acis_saverestore_export.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -// Define FileInfo -typedef struct -{ - PyObject_HEAD - FileInfo *_acis_obj; -} ACIS_SaveRestore_FileInfo; - -bool ACIS_SAVERESTORE_EXPORT _ACIS_check_FileInfo(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_SAVERESTORE_H diff --git a/src/acis_spa.cpp b/src/acis_spa.cpp new file mode 100644 index 0000000..5e867d3 --- /dev/null +++ b/src/acis_spa.cpp @@ -0,0 +1,25 @@ +#include "acis_spa.h" + + +PyObject * +a3dp_spa_unlock_products(PyObject *self, PyObject *arg) +{ + // Check if the input is a string + if (!PyUnicode_Check(arg)) + { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; + } + + // Convert PyObject to C-style string + const char *unlock_str = PyUnicode_AsUTF8(arg); + + // Call ACIS Licensing API + spa_unlock_result out = spa_unlock_products(unlock_str); + + // If license is good, then return True. Otherwise, return the licensing error message + if (SPA_UNLOCK_PASS == out.get_state()) + Py_RETURN_TRUE; + else + return PyUnicode_FromString(out.get_message_text()); +} diff --git a/src/acis_query.h b/src/acis_spa.h similarity index 53% rename from src/acis_query.h rename to src/acis_spa.h index e176d95..9764acd 100644 --- a/src/acis_query.h +++ b/src/acis_spa.h @@ -9,18 +9,21 @@ * */ -#ifndef ACIS_GEOMETRIC_OPERATORS_H -#define ACIS_GEOMETRIC_OPERATORS_H +#ifndef A3D_SPA_H +#define A3D_SPA_H #include -#include +#include "acis_includes.h" -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "acis_lists.h" -#include "utilities.h" +#ifdef __cplusplus +extern "C" { +#endif -#include "acis_query_export.h" +PyObject *a3dp_spa_unlock_products(PyObject *self, PyObject *arg); -#endif // !ACIS_GEOMETRIC_OPERATORS_H +#ifdef __cplusplus +} +#endif + +#endif // !A3D_SPA_H diff --git a/src/acis_sweeping.cpp b/src/acis_sweeping.cpp deleted file mode 100644 index 89f6e65..0000000 --- a/src/acis_sweeping.cpp +++ /dev/null @@ -1,551 +0,0 @@ -#include "acis_sweeping.h" - - -/** - * make_sweep_path_options class - */ - -static void -ACIS_Sweeping_dealloc_SweepPathOptions(ACIS_Sweeping_SweepPathOptions *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_Sweeping_new_SweepPathOptions(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_Sweeping_SweepPathOptions *self; - - self = (ACIS_Sweeping_SweepPathOptions *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_Sweeping_init_SweepPathOptions(ACIS_Sweeping_SweepPathOptions *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW make_sweep_path_options(); - - return 0; -} - -static PyMemberDef - ACIS_Sweeping_members_SweepPathOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Sweeping_methods_SweepPathOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Sweeping_type_SweepPathOptions = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.make_sweep_path_options", /* tp_name */ - sizeof(ACIS_Sweeping_SweepPathOptions), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Sweeping_dealloc_SweepPathOptions, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Sweeping_methods_SweepPathOptions, /* tp_methods */ - ACIS_Sweeping_members_SweepPathOptions, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Sweeping_init_SweepPathOptions, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Sweeping_new_SweepPathOptions, /* tp_new */ - }; - - -/** - * sweep_bool_type enum - */ - -static PyTypeObject - ACIS_Sweeping_type_SweepBoolType = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_bool_type", /* tp_name */ - sizeof(ACIS_Sweeping_SweepBoolType), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Sweep to body boolean operation type", /* tp_doc */ - }; - - -/** - * sweep_options class - */ - -static void -ACIS_Sweeping_dealloc_SweepOptions(ACIS_Sweeping_SweepOptions *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_Sweeping_new_SweepOptions(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_Sweeping_SweepOptions *self; - - self = (ACIS_Sweeping_SweepOptions *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_Sweeping_init_SweepOptions(ACIS_Sweeping_SweepOptions *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW sweep_options(); - - return 0; -} - -static PyObject * -ACIS_Sweeping_method_SweepOptions_set_bool_type(ACIS_Sweeping_SweepOptions *self, PyObject *args, PyObject *kwargs) -{ - // Just a testing... - self->_acis_obj->set_bool_type(KEEP_BOTH); - - Py_RETURN_NONE; -} - -static PyGetSetDef - ACIS_Sweeping_getseters_SweepOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Sweeping_members_SweepOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Sweeping_methods_SweepOptions[] = - { - { "set_bool_type", (PyCFunction) ACIS_Sweeping_method_SweepOptions_set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Sweeping_type_SweepOptions = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_options", /* tp_name */ - sizeof(ACIS_Sweeping_SweepOptions), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Sweeping_dealloc_SweepOptions, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Sweeping_methods_SweepOptions, /* tp_methods */ - ACIS_Sweeping_members_SweepOptions, /* tp_members */ - ACIS_Sweeping_getseters_SweepOptions, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Sweeping_init_SweepOptions, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Sweeping_new_SweepOptions, /* tp_new */ - }; - - -/** - * Sweeping API Interface Functions - */ - -static PyObject * -ACIS_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pts = NULL, *input_path = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pts", - (char *) "path", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pts, &input_path)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_EDGE(input_path)) - { - PyErr_SetString(PyExc_TypeError, "Second argument (path) must be an EDGE object"); - return NULL; - } - - // The first object must be a python sequence containing SPAposition objects - PyObject *seq = PySequence_Fast(input_pts, "First argument (pts) must be a sequence of SPAposition objects, such as a list or a tuple"); - - Py_ssize_t position_vector_size = PySequence_Fast_GET_SIZE(seq); - if (position_vector_size <= 0) - { - PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); - Py_DECREF(seq); - return NULL; - } - - // It seems unnecessary to implement a SPAposition container as python itself provides a handful of containers for every purpose - SPAposition_vector _pts; - - for (Py_ssize_t i = 0; i < position_vector_size; i++) - { - PyObject *pt_temp; - pt_temp = PySequence_Fast_GET_ITEM(seq, i); - if (!_ACIS_check_SPAposition(pt_temp)) - { - PyErr_SetString(PyExc_TypeError, "Sequence must contain SPAposition objects"); - Py_DECREF(seq); - return NULL; - } - _pts.push_back(*((ACIS_GeometricAtoms_SPAposition *) pt_temp)->_acis_obj); - } - - API_BEGIN - - EDGE *&_path = (EDGE *&) ((ACIS_Entity_EDGE *) input_path)->base_obj._acis_obj; - - // Don't use make_sweep_path_options for now - result = api_make_sweep_path(_pts, _path); - - API_END - - // PySequence_Fast returns a new reference - Py_DECREF(seq); - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Clear SPAposition container - _pts.clear(); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "arg1", - (char *) "arg2", - (char *) "arg3", - (char *) "arg4", - (char *) "arg5", - NULL - }; - - // Try to parse input arguments and/or keywords (hold sweep_options for now) - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO|O", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5)) - return NULL; - - /* - * IMPORTANT NOTE: This function wraps all 4 api_sweep_with_options overloads in one single Python function. - * The reason is that Python doesn't allow overloading with same function names but different signatures. - */ - - // In all overloads, first argument is always an ENTITY object - if (!_ACIS_check_ENTITY(input_arg1)) - { - PyErr_SetString(PyExc_TypeError, "First argument must be an ENTITY object"); - return NULL; - } - - API_BEGIN - - ENTITY *&_ent = (ENTITY *&) ((ACIS_Entity_ENTITY *) input_arg1)->_acis_obj; - - // Check if we are using the sweep along the axis overload - if (input_arg5 != NULL) - { - if (!_ACIS_check_SPAposition(input_arg2)) - { - PyErr_SetString(PyExc_TypeError, "Second argument must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_SPAvector(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Third argument must be a SPAvector object"); - return NULL; - } - - if (!_ACIS_check_SweepOptions(input_arg4)) - { - PyErr_SetString(PyExc_TypeError, "Fourth argument must be a sweep_options object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_arg5)) - { - PyErr_SetString(PyExc_TypeError, "Fifth argument must be a BODY object"); - return NULL; - } - - SPAposition *&_root = (SPAposition *&) ((ACIS_GeometricAtoms_SPAposition *) input_arg2)->_acis_obj; - SPAvector *&_axis = (SPAvector *&) ((ACIS_GeometricAtoms_SPAvector *) input_arg3)->_acis_obj; - sweep_options *&_opts = (sweep_options *&) ((ACIS_Sweeping_SweepOptions *) input_arg4)->_acis_obj; - BODY *&_new_body = (BODY *&) ((ACIS_Entity_BODY *) input_arg5)->base_obj._acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, *_root, *_axis, _opts, _new_body); - - } - else - { - // We must be using the other overloads, then the 3rd argument must be a sweep_options object - if (!_ACIS_check_SweepOptions(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Third argument must be a sweep_options object"); - return NULL; - } - - sweep_options *&_opts = (sweep_options *&) ((ACIS_Sweeping_SweepOptions *) input_arg3)->_acis_obj; - - // and the 4th argument must be a BODY object - if (!_ACIS_check_BODY(input_arg4)) - { - PyErr_SetString(PyExc_TypeError, "Fourth argument must be a BODY object"); - return NULL; - } - - BODY *&_new_body = (BODY *&) ((ACIS_Entity_BODY *) input_arg4)->base_obj._acis_obj; - - // Check for sweeping along a given edge or a wire overload - if (_ACIS_check_ENTITY(input_arg2)) - { - ENTITY *&_path = (ENTITY *&) ((ACIS_Entity_ENTITY *) input_arg2)->_acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, _path, _opts, _new_body); - } - else if (PyFloat_Check(input_arg2)) - { - // We must be using sweeping along a specified distance overload - double _distance = PyFloat_AsDouble(input_arg2); - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, _distance, _opts, _new_body); - } - else if (_ACIS_check_SPAvector(input_arg2)) - { - // We must be using sweeping along a specified vector overload - SPAvector *&_vec = (SPAvector *&) ((ACIS_GeometricAtoms_SPAvector *) input_arg2)->_acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, *_vec, _opts, _new_body); - } - else - { - PyErr_SetString(PyExc_TypeError, "Second argument must be an ENTITY, float or SPAvector object"); - return NULL; - } - - } - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyMethodDef - module_methods[] = - { - { "api_make_sweep_path", (PyCFunction) ACIS_api_make_sweep_path, METH_VARARGS | METH_KEYWORDS, "Constructs a path useful for creating a swept surface" }, - { "api_sweep_with_options", (PyCFunction) ACIS_api_sweep_with_options, METH_VARARGS | METH_KEYWORDS, "Sweeps the given profile along an edge, a distance, a vector or an axis" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Sweeping"; -const char *module_documentation = "Contains 3D ACIS Modeler sweeping API related classes and functions"; - -static struct PyModuleDef - ACIS_Sweeping_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Sweeping(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Sweeping_module); - if (m == NULL) - return NULL; - - // Create a dictionary object for sweep_bool_type enum - PyObject *_sbt_dict; - _sbt_dict = PyDict_New(); - if (_sbt_dict != NULL) - { - PyDict_SetItemString(_sbt_dict, "UNITE", PyLong_FromLong(0L)); - PyDict_SetItemString(_sbt_dict, "INTERSECT", PyLong_FromLong(1L)); - PyDict_SetItemString(_sbt_dict, "SUBTRACT", PyLong_FromLong(2L)); - PyDict_SetItemString(_sbt_dict, "LIMIT", PyLong_FromLong(3L)); - PyDict_SetItemString(_sbt_dict, "KEEP_BOTH", PyLong_FromLong(4L)); - } - - // sweep_bool_type - ACIS_Sweeping_type_SweepBoolType.tp_dict = _sbt_dict; - if (PyType_Ready(&ACIS_Sweeping_type_SweepBoolType) < 0) - return NULL; - Py_INCREF(&ACIS_Sweeping_type_SweepBoolType); - PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &ACIS_Sweeping_type_SweepBoolType); - - // sweep_options - if (PyType_Ready(&ACIS_Sweeping_type_SweepOptions) < 0) - return NULL; - Py_INCREF(&ACIS_Sweeping_type_SweepOptions); - PyModule_AddObject(m, "sweep_options", (PyObject *) &ACIS_Sweeping_type_SweepOptions); - - // make_sweep_path_options - if (PyType_Ready(&ACIS_Sweeping_type_SweepPathOptions) < 0) - return NULL; - Py_INCREF(&ACIS_Sweeping_type_SweepPathOptions); - PyModule_AddObject(m, "make_sweep_path_options", (PyObject *) &ACIS_Sweeping_type_SweepPathOptions); - - return m; -} - -PyObject *_ACIS_new_SweepBoolType() -{ - return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepBoolType, NULL); -} - -bool _ACIS_check_SweepBoolType(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepBoolType; -} - -PyObject *_ACIS_new_SweepOptions() -{ - return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepOptions, NULL); -} - -bool _ACIS_check_SweepOptions(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepOptions; -} - -PyObject *_ACIS_new_SweepPathOptions() -{ - return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepPathOptions, NULL); -} - -bool _ACIS_check_SweepPathOptions(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepPathOptions; -} diff --git a/src/acis_sweeping.h b/src/acis_sweeping.h deleted file mode 100644 index 0a5d9da..0000000 --- a/src/acis_sweeping.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_SWEEPING_H -#define ACIS_SWEEPING_H - -#include -#include - -#include -#include -#include -#include - -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "utilities.h" - -#include "acis_sweeping_export.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -// Define sweep_bool_type enum -typedef struct { - PyObject_HEAD -} ACIS_Sweeping_SweepBoolType; - -PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepBoolType(); - -bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepBoolType(PyObject *ob); - -// Define sweep_options -typedef struct -{ - PyObject_HEAD - sweep_options *_acis_obj; -} ACIS_Sweeping_SweepOptions; - -PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepOptions(); - -bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepOptions(PyObject *ob); - -// Define make_sweep_path_options -typedef struct -{ - PyObject_HEAD - make_sweep_path_options *_acis_obj; -} ACIS_Sweeping_SweepPathOptions; - -PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepPathOptions(); - -bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepPathOptions(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_SWEEPING_H diff --git a/src/utilities.h b/src/utilities.h index dec548b..8129a90 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -9,14 +9,21 @@ * */ -#ifndef ACIS_UTILITIES_H -#define ACIS_UTILITIES_H +#ifndef A3DPY_UTILITIES_H +#define A3DPY_UTILITIES_H #include -#include -#include +#include "acis_includes.h" + +#ifdef __cplusplus +extern "C" { +#endif bool check_outcome(outcome &_retval); -#endif //ACIS_UTILITIES_H +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_UTILITIES_H From ad9bf9a1ba6136c93305adc84c2f22b5a71e4bb6 Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Sun, 10 Dec 2017 00:57:14 -0600 Subject: [PATCH 4/9] Revert "Add a custom target for install to ease up working with CLion" This reverts commit bbdc387ed833433d2eb5589503f09858af770d02. --- CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 969c389..91743f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,11 +268,3 @@ set_property( APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "__init__.py" ) - -# -# Create a custom install target for calling inside Jetbrains CLion -# -add_custom_target( install_${PROJECT_NAME} - $(CMAKE_COMMAND) --build . --target install - COMMENT "Installing ${PROJECT_NAME}..." - ) From 6358725740b75498369f1a51ec2f917e0df49279 Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Sun, 10 Dec 2017 00:58:13 -0600 Subject: [PATCH 5/9] Revert "Revert "Add a custom target for install to ease up working with CLion"" This reverts commit ad9bf9a1ba6136c93305adc84c2f22b5a71e4bb6. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91743f8..969c389 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,3 +268,11 @@ set_property( APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "__init__.py" ) + +# +# Create a custom install target for calling inside Jetbrains CLion +# +add_custom_target( install_${PROJECT_NAME} + $(CMAKE_COMMAND) --build . --target install + COMMENT "Installing ${PROJECT_NAME}..." + ) From 227b14923fafe27145f4794b7690cd99b5315d57 Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Sun, 10 Dec 2017 00:58:35 -0600 Subject: [PATCH 6/9] Revert "Major reorganization" This reverts commit f551018324d52706f1781fcb2b6fd1c093a1bd3a. --- CMakeLists.txt | 367 +++- CONTRIBUTING.md | 4 +- examples/01_generate_solid_block.py | 18 +- examples/02_boolean_subtract.py | 24 +- examples/03_sweeping.py | 34 +- examples/04_face_counting.py | 18 +- src/acis_api.cpp | 1445 -------------- src/acis_api.h | 65 - src/acis_booleans.cpp | 333 ++++ src/acis_booleans.h | 36 + src/acis_classes.cpp | 1694 ---------------- src/acis_classes.h | 841 -------- src/acis_entity.cpp | 2028 +++++++++++++------ src/acis_entity.h | 1167 ++--------- src/acis_enums.cpp | 22 - src/acis_enums.h | 102 - src/acis_geometric_atoms.cpp | 2778 +++++++++++++++++++++++++++ src/acis_geometric_atoms.h | 114 ++ src/acis_includes.h | 36 - src/acis_licensing.cpp | 61 + src/acis_lists.cpp | 440 +++++ src/acis_lists.h | 46 + src/acis_modeler.cpp | 850 +++++--- src/acis_modeler.h | 17 +- src/acis_operators.cpp | 802 -------- src/acis_operators.h | 50 - src/acis_query.cpp | 181 ++ src/{acis_spa.h => acis_query.h} | 21 +- src/acis_saverestore.cpp | 506 +++++ src/acis_saverestore.h | 44 + src/acis_spa.cpp | 25 - src/acis_sweeping.cpp | 551 ++++++ src/acis_sweeping.h | 69 + src/utilities.h | 17 +- 34 files changed, 7795 insertions(+), 7011 deletions(-) delete mode 100644 src/acis_api.cpp delete mode 100644 src/acis_api.h create mode 100644 src/acis_booleans.cpp create mode 100644 src/acis_booleans.h delete mode 100644 src/acis_classes.cpp delete mode 100644 src/acis_classes.h delete mode 100644 src/acis_enums.cpp delete mode 100644 src/acis_enums.h create mode 100644 src/acis_geometric_atoms.cpp create mode 100644 src/acis_geometric_atoms.h delete mode 100644 src/acis_includes.h create mode 100644 src/acis_licensing.cpp create mode 100644 src/acis_lists.cpp create mode 100644 src/acis_lists.h delete mode 100644 src/acis_operators.cpp delete mode 100644 src/acis_operators.h create mode 100644 src/acis_query.cpp rename src/{acis_spa.h => acis_query.h} (53%) create mode 100644 src/acis_saverestore.cpp create mode 100644 src/acis_saverestore.h delete mode 100644 src/acis_spa.cpp create mode 100644 src/acis_sweeping.cpp create mode 100644 src/acis_sweeping.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 969c389..6510ba1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8 ) -project( ACIS-Python3 CXX ) +project( ACISPython3 CXX ) # # Application Configuration @@ -109,27 +109,360 @@ else() message( FATAL_ERROR "A valid Python interpreter is required for finding Python's site-packages directory!" ) endif() + +# +# ACIS Python Module - Licensing +# + +# Set source files +set( ACIS_SOURCES_Licensing + src/acis_licensing.cpp + ) + +# Generate Python module +add_library( Licensing SHARED ${ACIS_SOURCES_Licensing} ) + +# Set link targets +target_link_libraries( Licensing ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) + +# Add the build location to the include directories +target_include_directories( Licensing PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET Licensing PROPERTY CXX_STANDARD 11 ) +set_property( TARGET Licensing PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( Licensing PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( Licensing PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( Licensing PROPERTIES PREFIX "" ) + + +# +# ACIS Python Module - Entity (ENTITY, BODY, FACE, etc.) +# + +# Set source files +set( ACIS_SOURCES_Entity + src/acis_entity.h + src/acis_entity.cpp + ${PROJECT_BINARY_DIR}/acis_entity_export.h + ) + +# Generate Python module +add_library( Entity SHARED ${ACIS_SOURCES_Entity} ) + +# Generate export header file +generate_export_header( Entity + BASE_NAME acis_entity + ) + +# Set link targets +target_link_libraries( Entity ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} GeometricAtoms ) + +# Add the build location to the include directories +target_include_directories( Entity PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET Entity PROPERTY CXX_STANDARD 11 ) +set_property( TARGET Entity PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( Entity PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( Entity PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( Entity PROPERTIES PREFIX "" ) + + # -# ACIS Python Module +# ACIS Python Module - Geometric Atoms (SPAposition, SPApar_pos, etc.) +# + +# Set source files +set( ACIS_SOURCES_GeometricAtoms + src/acis_geometric_atoms.h + src/acis_geometric_atoms.cpp + ${PROJECT_BINARY_DIR}/acis_geometric_atoms_export.h + ) + +# Generate Python module +add_library( GeometricAtoms SHARED ${ACIS_SOURCES_GeometricAtoms} ) + +# Generate export header file +generate_export_header( GeometricAtoms + BASE_NAME acis_geometric_atoms + ) + +# Set link targets +target_link_libraries( GeometricAtoms ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) + +# Add the build location to the include directories +target_include_directories( GeometricAtoms PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET GeometricAtoms PROPERTY CXX_STANDARD 11 ) +set_property( TARGET GeometricAtoms PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( GeometricAtoms PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( GeometricAtoms PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( GeometricAtoms PROPERTIES PREFIX "" ) + + +# +# ACIS Python Module - Save & Restore (FileInfo, etc.) +# + +# Set source files +set( ACIS_SOURCES_SaveRestore + src/acis_saverestore.h + src/acis_saverestore.cpp + src/utilities.cpp + src/utilities.h + ${PROJECT_BINARY_DIR}/acis_saverestore_export.h + ) + +# Generate Python module +add_library( SaveRestore SHARED ${ACIS_SOURCES_SaveRestore} ) + +# Generate export header file +generate_export_header( SaveRestore + BASE_NAME acis_saverestore + ) + +# Set link targets +target_link_libraries( SaveRestore ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Lists ) + +# Add the build location to the include directories +target_include_directories( SaveRestore PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET SaveRestore PROPERTY CXX_STANDARD 11 ) +set_property( TARGET SaveRestore PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( SaveRestore PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( SaveRestore PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( SaveRestore PROPERTIES PREFIX "" ) + + +# +# ACIS Python Module - Lists (ENTITY_LIST, etc.) +# + +# Set source files +set( ACIS_SOURCES_Lists + src/acis_lists.h + src/acis_lists.cpp + ${PROJECT_BINARY_DIR}/acis_lists_export.h + ) + +# Generate Python module +add_library( Lists SHARED ${ACIS_SOURCES_Lists} ) + +# Generate export header file +generate_export_header( Lists + BASE_NAME acis_lists + ) + +# Set link targets +target_link_libraries( Lists ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity ) + +# Add the build location to the include directories +target_include_directories( Lists PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET Lists PROPERTY CXX_STANDARD 11 ) +set_property( TARGET Lists PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( Lists PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( Lists PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( Lists PROPERTIES PREFIX "" ) + + +# +# ACIS Python Module - Sweeping API +# + +# Set source files +set( ACIS_SOURCES_Sweeping + src/acis_sweeping.cpp + src/acis_sweeping.h + src/utilities.cpp + src/utilities.h + ${PROJECT_BINARY_DIR}/acis_sweeping_export.h + ) + +# Generate Python module +add_library( Sweeping SHARED ${ACIS_SOURCES_Sweeping} ) + +# Generate export header file +generate_export_header( Sweeping + BASE_NAME acis_sweeping + ) + +# Set link targets. Note that Modeler has dependencies towards most helper modules. +target_link_libraries( Sweeping ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity GeometricAtoms ) + +# Add the build location to the include directories +target_include_directories( Sweeping PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET Sweeping PROPERTY CXX_STANDARD 11 ) +set_property( TARGET Sweeping PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( Sweeping PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( Sweeping PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( Sweeping PROPERTIES PREFIX "" ) + + +# +# ACIS Python Module - Booleans API +# + +# Set source files +set( ACIS_SOURCES_Booleans + src/acis_booleans.h + src/acis_booleans.cpp + src/utilities.cpp + src/utilities.h + ${PROJECT_BINARY_DIR}/acis_booleans_export.h + ) + +# Generate Python module +add_library( Booleans SHARED ${ACIS_SOURCES_Booleans} ) + +# Generate export header file +generate_export_header( Booleans + BASE_NAME acis_booleans + ) + +# Set link targets +target_link_libraries( Booleans ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity ) + +# Add the build location to the include directories +target_include_directories( Booleans PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET Booleans PROPERTY CXX_STANDARD 11 ) +set_property( TARGET Booleans PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( Booleans PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( Booleans PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( Booleans PROPERTIES PREFIX "" ) + + +# +# ACIS Python Module - Query API +# + +# Set source files +set( ACIS_SOURCES_Query + src/acis_query.cpp + src/acis_query.h + src/utilities.cpp + src/utilities.h + ${PROJECT_BINARY_DIR}/acis_query_export.h + ) + +# Generate Python module +add_library( Query SHARED ${ACIS_SOURCES_Query} ) + +# Generate export header file +generate_export_header( Query + BASE_NAME acis_query + ) + +# Set link targets. Note that Modeler has dependencies towards most helper modules. +target_link_libraries( Query ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity GeometricAtoms Lists ) + +# Add the build location to the include directories +target_include_directories( Query PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) + +# Set required C++ standard +set_property( TARGET Query PROPERTY CXX_STANDARD 11 ) +set_property( TARGET Query PROPERTY CXX_STANDARD_REQUIRED ON ) + +# Add suffix to debug builds +if( WIN32 ) + set_target_properties( Query PROPERTIES DEBUG_POSTFIX "_d" ) +endif() + +# On Windows, Python modules have .pyd filename extension +if( WIN32 AND NOT CYGWIN ) + set_target_properties( Query PROPERTIES SUFFIX ".pyd" ) +endif() + +# This is only needed for the python case where a modulename.so is generated +set_target_properties( Query PROPERTIES PREFIX "" ) + + +# +# ACIS Python Module - Modeler Core # # Set source files set( ACIS_SOURCES_Modeler - src/acis_includes.h src/acis_modeler.cpp src/acis_modeler.h - src/acis_api.cpp - src/acis_api.h - src/acis_classes.cpp - src/acis_classes.h - src/acis_entity.cpp - src/acis_entity.h - src/acis_enums.cpp - src/acis_enums.h - src/acis_operators.cpp - src/acis_operators.h - src/acis_spa.cpp - src/acis_spa.h src/utilities.cpp src/utilities.h ) @@ -138,7 +471,7 @@ set( ACIS_SOURCES_Modeler add_library( Modeler SHARED ${ACIS_SOURCES_Modeler} ) # Set link targets. Note that Modeler has dependencies towards most helper modules. -target_link_libraries( Modeler ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) +target_link_libraries( Modeler ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity Lists SaveRestore GeometricAtoms ) # Add the build location to the include directories target_include_directories( Modeler PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) @@ -167,7 +500,7 @@ set_target_properties( Modeler PROPERTIES PREFIX "" ) # Install Python modules to APP_INSTALL_DIR install( - TARGETS Modeler + TARGETS Modeler Licensing Entity Lists SaveRestore GeometricAtoms Sweeping Query Booleans DESTINATION ${APP_INSTALL_DIR}/${APP_MODULE_NAME} ) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd23451..5b94548 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,8 +28,8 @@ I would like to introduce some rules on contributing to this module. #### Naming conventions in the Python module * Python objects are defined as `ACIS_{ModuleName}_{ACISName}` and located in the header files -* Type functions are defined as `ACIS_{ModuleName}_{function_name}_{ACISName}`, e.g. _a3dp_init_SPAposition_ -* Methods for types are defined as `ACIS_{ModuleName}_method_{ACISName}_{MethodName}`, e.g. _a3dp_method_ENTITY_LIST_add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side +* Type functions are defined as `ACIS_{ModuleName}_{function_name}_{ACISName}`, e.g. _ACIS_GeometricAtoms_init_SPAposition_ +* Methods for types are defined as `ACIS_{ModuleName}_method_{ACISName}_{MethodName}`, e.g. _ACIS_Lists_method_ENTITY_LIST_add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side * Module variables are defined as `ACIS_{ModuleName}_{function_name}`, e.g. _ACIS_Topology_module_ * Module init functions are defined as `PyInit_{ModuleName}` * ACIS API calls are defined as `ACIS_{API Call}`, e.g. _ACIS_api_start_modeller_ which corresponds to _api_start_modeller()_ on the C++ side diff --git a/examples/01_generate_solid_block.py b/examples/01_generate_solid_block.py index f8ab8b7..a4d2b3f 100644 --- a/examples/01_generate_solid_block.py +++ b/examples/01_generate_solid_block.py @@ -8,19 +8,19 @@ """ from ACIS import utilities as utils -from ACIS import Modeler +from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Modeler.spa_unlock_products(unlock_key) +Licensing.spa_unlock_products(unlock_key) # Generate a simple solid block -pt1 = Modeler.SPAposition(0.0, 0.0, 0.0) -pt2 = Modeler.SPAposition(50.0, 50.0, 25.0) -block = Modeler.BODY() +pt1 = GeometricAtoms.SPAposition(0.0, 0.0, 0.0) +pt2 = GeometricAtoms.SPAposition(50.0, 50.0, 25.0) +block = Entity.BODY() Modeler.api_solid_block(pt1, pt2, block) @@ -29,24 +29,24 @@ block.id = 1 # Prepare for saving -save_list = Modeler.ENTITY_LIST() +save_list = Lists.ENTITY_LIST() save_list.add(block) # Set file name filename = "ACIS_Ex01.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = Modeler.FileInfo() +file_info = SaveRestore.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -Modeler.api_set_file_info(file_info, product_id=True, units=True) +SaveRestore.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -Modeler.api_save_entity_list(filename, True, save_list) +SaveRestore.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/02_boolean_subtract.py b/examples/02_boolean_subtract.py index fec05bc..c1fa636 100644 --- a/examples/02_boolean_subtract.py +++ b/examples/02_boolean_subtract.py @@ -10,31 +10,31 @@ # This example is taken from the book "Rapid Prototyping and Engineering Applications" by Frank W. Liou (Example 5.1) from ACIS import utilities as utils -from ACIS import Modeler +from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Booleans # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Modeler.spa_unlock_products(unlock_key) +Licensing.spa_unlock_products(unlock_key) # Make a cuboid -block = Modeler.BODY() +block = Entity.BODY() Modeler.api_make_cuboid(150, 75, 25, block) # Generate and apply transformation to the cuboid -block_vector = Modeler.SPAvector(0.0, 0.0, 12.7) -block_transf = Modeler.translate_transf(block_vector) +block_vector = GeometricAtoms.SPAvector(0.0, 0.0, 12.7) +block_transf = GeometricAtoms.translate_transf(block_vector) Modeler.api_apply_transf(block, block_transf) # Make a frustum -cylinder = Modeler.BODY() +cylinder = Entity.BODY() Modeler.api_make_frustum(19.05, 12.7, 12.7, 12.7, cylinder) # Generate and apply transformation to the frustum -cylinder_vector = Modeler.SPAvector(0.0, 0.0, 6.35) -cylinder_transf = Modeler.translate_transf(cylinder_vector) +cylinder_vector = GeometricAtoms.SPAvector(0.0, 0.0, 6.35) +cylinder_transf = GeometricAtoms.translate_transf(cylinder_vector) Modeler.api_apply_transf(cylinder, cylinder_transf) # Subtract frustum from cuboid @@ -45,24 +45,24 @@ block.id = 1 # Prepare for saving -save_list = Modeler.ENTITY_LIST() +save_list = Lists.ENTITY_LIST() save_list.add(block) # Set file name filename = "ACIS_Ex02.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = Modeler.FileInfo() +file_info = SaveRestore.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -Modeler.api_set_file_info(file_info, product_id=True, units=True) +SaveRestore.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -Modeler.api_save_entity_list(filename, True, save_list) +SaveRestore.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/03_sweeping.py b/examples/03_sweeping.py index c90b04e..3664f14 100644 --- a/examples/03_sweeping.py +++ b/examples/03_sweeping.py @@ -8,47 +8,47 @@ """ from ACIS import utilities as utils -from ACIS import Modeler +from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Sweeping, Query # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Modeler.spa_unlock_products(unlock_key) +Licensing.spa_unlock_products(unlock_key) # Make a cuboid -block = Modeler.BODY() +block = Entity.BODY() Modeler.api_make_cuboid(150, 75, 25, block) # Get faces of the cuboid -face_list = Modeler.ENTITY_LIST() -Modeler.api_get_faces(block, face_list) +face_list = Lists.ENTITY_LIST() +Query.api_get_faces(block, face_list) # Choose any face from the cuboid's face list block_face = face_list.first() # Convert the chosen face into a sheet body -sheet_body = Modeler.BODY() +sheet_body = Entity.BODY() Modeler.api_sheet_from_ff([block_face], sheet_body) # Make a sweep path -pt1 = Modeler.SPAposition(0.0, 0.0, 0.0) -pt2 = Modeler.SPAposition(10.0, 55.0, 23.0) -sweep_path = Modeler.EDGE() -Modeler.api_make_sweep_path([pt1, pt2], sweep_path) +pt1 = GeometricAtoms.SPAposition(0.0, 0.0, 0.0) +pt2 = GeometricAtoms.SPAposition(10.0, 55.0, 23.0) +sweep_path = Entity.EDGE() +Sweeping.api_make_sweep_path([pt1, pt2], sweep_path) # Sweep the chosen face using the sweep path -opts = Modeler.sweep_options() -swept_body = Modeler.BODY() -Modeler.api_sweep_with_options(sheet_body, sweep_path, opts, swept_body) +opts = Sweeping.sweep_options() +swept_body = Entity.BODY() +Sweeping.api_sweep_with_options(sheet_body, sweep_path, opts, swept_body) # Assign attributes after generation sheet_body.name = "Swept FACE" sheet_body.id = 1 # Prepare for saving -save_list = Modeler.ENTITY_LIST() +save_list = Lists.ENTITY_LIST() # api_sweep_with_options will modify sheet_body object as defined in its documentation save_list.add(sheet_body) @@ -56,14 +56,14 @@ filename = "ACIS_Ex03.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = Modeler.FileInfo() +file_info = SaveRestore.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -Modeler.api_set_file_info(file_info, product_id=True, units=True) +SaveRestore.api_set_file_info(file_info, product_id=True, units=True) # Save the model as a SAT file -Modeler.api_save_entity_list(filename, True, save_list) +SaveRestore.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/04_face_counting.py b/examples/04_face_counting.py index 2a8cbec..8f4dec6 100644 --- a/examples/04_face_counting.py +++ b/examples/04_face_counting.py @@ -8,17 +8,17 @@ """ from ACIS import utilities as utils -from ACIS import Modeler +from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Query # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Modeler.spa_unlock_products(unlock_key) +Licensing.spa_unlock_products(unlock_key) # Generate a truncated cone -frustum = Modeler.BODY() +frustum = Entity.BODY() Modeler.api_make_frustum(50, 20, 30, 10, frustum) # Assign attributes after generation @@ -26,32 +26,32 @@ frustum.id = 1 # Loop through the face list and print out the name of the entity type -face_list = Modeler.ENTITY_LIST() -Modeler.api_get_faces(frustum, face_list) +face_list = Lists.ENTITY_LIST() +Query.api_get_faces(frustum, face_list) for f in face_list.array(): fs = f.geometry() print(fs.type_name()) # Prepare for saving -save_list = Modeler.ENTITY_LIST() +save_list = Lists.ENTITY_LIST() save_list.add(frustum) # Set file name filename = "ACIS_Ex04.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = Modeler.FileInfo() +file_info = SaveRestore.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -Modeler.api_set_file_info(file_info, product_id=True, units=True) +SaveRestore.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -Modeler.api_save_entity_list(filename, True, save_list) +SaveRestore.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/src/acis_api.cpp b/src/acis_api.cpp deleted file mode 100644 index 44442ce..0000000 --- a/src/acis_api.cpp +++ /dev/null @@ -1,1445 +0,0 @@ -#include "acis_api.h" - - -bool disabled_acis_freelisting = false; - -PyObject * -a3dp_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_n = 0; - int input_freelisting = 1; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "n", - (char *) "freelisting", - NULL - }; - - // Try to parse input arguments and/or keywords - // api_start_modeller does not utilize the "n" argument, but following the implementation but make it optional - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist, &input_n, &input_freelisting)) - return NULL; - - // Disable ACIS freelisting facility if freelisting=False - if (!input_freelisting) - { - // Display a warning message - PyErr_WarnEx(PyExc_Warning, "Disabling ACIS freelisting...", 0); - // Disable ACIS freelisting - base_configuration base_config; - base_config.enable_freelists = FALSE; - base_config.raw_allocator = malloc; - base_config.raw_destructor = free; - initialize_base(&base_config); - // Set the global variable for terminate_nase - disabled_acis_freelisting = true; - } - - // Call ACIS API and check outcome - outcome result; - result = api_start_modeller(input_n); - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_stop_modeller(PyObject *self) -{ - // Call ACIS API and check outcome - outcome result; - result = api_stop_modeller(); - - // If ACIS freelisting disabled, we need to call terminate_base() - if (disabled_acis_freelisting) - { - // Display a warning message - PyErr_WarnEx(PyExc_Warning, "Terminating ACIS...", 0); - terminate_base(); - } - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_is_modeler_started(PyObject *self) -{ - // Initialize variables - logical check_modeler; - - // Call ACIS API - check_modeler = is_modeler_started(); - - // Return Python value - if (check_modeler) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -PyObject * -a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - double input_value; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sd", kwlist, &input_name, &input_value)) - return NULL; - - API_BEGIN - - result = api_set_dbl_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - int input_value; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si", kwlist, &input_name, &input_value)) - return NULL; - - API_BEGIN - - result = api_set_int_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - const char *input_value = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &input_name, &input_value)) - return NULL; - - API_BEGIN - - result = api_set_str_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL, *input_block = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - (char *) "block", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_pt1, &input_pt2, &input_block)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_SPAposition(input_pt1)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a SPAposition object"); - return NULL; - } - - if (!_PyCheck_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAposition object"); - return NULL; - } - - if (!_PyCheck_BODY(input_block)) - { - PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - SPAposition *_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; - SPAposition *_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; - BODY *&_block = (BODY *&) ((a3dp_BODY *) input_block)->base_obj._acis_obj; - - // Call ACIS API - result = api_solid_block(*_pt1, *_pt2, _block); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_x, input_y, input_z; - PyObject *input_body = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - (char *) "body", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddO", kwlist, &input_x, &input_y, &input_z, &input_body)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_body)) - { - PyErr_SetString(PyExc_TypeError, "The fourth argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_body = (BODY *&) ((a3dp_BODY *) input_body)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_cuboid(input_x, input_y, input_z, _body); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2, input_top; - PyObject *input_frust = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "top", - (char *) "frust", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_frust)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_frust)) - { - PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_frust = (BODY *&) ((a3dp_BODY *) input_frust)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_frustum(input_height, input_radius1, input_radius2, input_top, _frust); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2; - int input_nsides; - PyObject *input_prism = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "nsides", - (char *) "frust", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_nsides, &input_prism)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_prism)) - { - PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_prism = (BODY *&) ((a3dp_BODY *) input_prism)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_prism(input_height, input_radius1, input_radius2, input_nsides, _prism); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2, input_top; - int input_nsides; - PyObject *input_pyramid = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "top", - (char *) "nsides", - (char *) "pyramid", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_nsides, &input_pyramid)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_pyramid)) - { - PyErr_SetString(PyExc_TypeError, "The sixth argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_pyramid = (BODY *&) ((a3dp_BODY *) input_pyramid)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_pyramid(input_height, input_radius1, input_radius2, input_top, input_nsides, _pyramid); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_radius; - PyObject *input_sph = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "radius", - (char *) "sph", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_radius, &input_sph)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_sph)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_sph = (BODY *&) ((a3dp_BODY *) input_sph)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_sphere(input_radius, _sph); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_major_r, input_minor_r; - PyObject *input_tor = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "major_radius", - (char *) "minor_radius", - (char *) "tor", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_major_r, &input_minor_r, &input_tor)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_tor)) - { - PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tor = (BODY *&) ((a3dp_BODY *) input_tor)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_torus(input_major_r, input_minor_r, _tor); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_entity = NULL, *input_trans = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "entity", - (char *) "trans", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity, &input_trans)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_entity)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); - return NULL; - } - - if (!_PyCheck_SPAtransf(input_trans)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAtransf object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - ENTITY *&_entity = ((a3dp_BODY *) input_entity)->base_obj._acis_obj; - SPAtransf *&_trans = ((a3dp_SPAtransf *) input_trans)->_acis_obj; - - // Call ACIS API - result = api_apply_transf(_entity, *_trans); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_entity = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "entity", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_entity)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - ENTITY *&_entity = ((a3dp_BODY *) input_entity)->base_obj._acis_obj; - - // Call ACIS API - result = api_remove_transf(_entity); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_faces = NULL, *input_body = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "faces", - (char *) "body", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_faces, &input_body)) - return NULL; - - // First argument must be a tuple of faces - PyObject *seq = PySequence_Fast(input_faces, "First argument must be a sequence of FACE objects"); - - // ACIS API has a limitation in api_sheet_from_ff function: As of version R2017, it can handle only 1 face - Py_ssize_t face_array_size = PySequence_Fast_GET_SIZE(seq); - if (face_array_size <= 0) - { - PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); - Py_DECREF(seq); - return NULL; - } - else if (face_array_size > 1) - { - PyErr_WarnEx(PyExc_Warning, "ACIS API does not support generation of sheet bodies from multiple faces.", 0); - } - - PyObject *faceobj = PySequence_Fast_GET_ITEM(seq, 0); - - API_BEGIN - - FACE *&_face = (FACE *&) ((a3dp_FACE *) faceobj)->base_obj._acis_obj; - - FACE *_faces[1]; - _faces[0] = _face; - - BODY *&_body = (BODY *&) ((a3dp_BODY *) input_body)->base_obj._acis_obj; - - result = api_sheet_from_ff(1, _faces, _body); - - API_END - - // PySequence_Fast generates a new reference - Py_DECREF(seq); - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -/** - * Booleans API Interface Functions - */ - -PyObject * -a3dp_api_unite(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_PyCheck_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_unite(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -PyObject * -a3dp_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_PyCheck_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_intersect(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -PyObject * -a3dp_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_PyCheck_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_subtract(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -PyObject * -a3dp_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_PyCheck_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_imprint(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -PyObject * -a3dp_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs) -{ - /* TO-DO: Implement api_boolean_chop_body */ - return NULL; -} - -PyObject * -a3dp_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs) -{ - // According to the documentation, Python 3 doesn't do good with FILE* objects, so we take "file name" as an input - const char *input_filename = NULL; - int input_savemode; - PyObject *input_entitylist = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "file_name", - (char *) "text_mode", - (char *) "entity_list_save", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO", kwlist, &input_filename, &input_savemode, &input_entitylist)) - return NULL; - - // Check if the input is an ENTITY_LIST - if (!_PyCheck_ENTITY_LIST(input_entitylist)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - // Using the file name input as a string, create a file handle - FILE *_file_handle = fopen(input_filename, "w"); - - // Check if the file has been opened correctly - if (_file_handle == NULL) - { - PyErr_SetString(PyExc_IOError, "Cannot open file for writing!"); - return NULL; - } - - // Set file writing mode - logical _text_mode = (input_savemode == 0) ? FALSE : TRUE; - - API_NOP_BEGIN - - // Convert PyObject to ENTITY_LIST - ENTITY_LIST *_save_list = ((a3dp_ENTITY_LIST *) input_entitylist)->_acis_obj; - - - // Call ACIS API and check outcome - result = api_save_entity_list(_file_handle, _text_mode, *_save_list); - - API_NOP_END - - // Don't forget to close the file handle - fclose(_file_handle); - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_product_id = 0; - int input_units = 0; - PyObject *input_info = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "info", - (char *) "product_id", - (char *) "units", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii", kwlist, &input_info, &input_product_id, &input_units)) - return NULL; - - // Check if we have a FileInfo object - if (!_PyCheck_FileInfo(input_info)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - // Set up the value of mask - bool _product_id = input_product_id != 0; - bool _units = input_units != 0; - - unsigned long _mask; - if (_product_id && !_units) - { - _mask = FileIdent; - } - else if (!_product_id && _units) - { - _mask = FileUnits; - } - else - { - _mask = FileUnits | FileIdent; - } - - API_BEGIN - - // Convert PyObject to FileInfo - FileInfo *_info = ((a3dp_FileInfo *) input_info)->_acis_obj; - - result = api_set_file_info(_mask, *_info); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_info = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "info", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_info)) - return NULL; - - // Check if we have a FileInfo object - if (_PyCheck_FileInfo(input_info)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to FileInfo - FileInfo *_info = ((a3dp_FileInfo *) input_info)->_acis_obj; - - result = api_get_file_info(*_info); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -PyObject * -a3dp_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_major_version, input_minor_version; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "major_version", - (char *) "minor_version", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_major_version, &input_minor_version)) - return NULL; - - API_BEGIN - - result = api_save_version(input_major_version, input_minor_version); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -/** - * Sweeping API Interface Functions - */ - -PyObject * -a3dp_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pts = NULL, *input_path = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "pts", - (char *) "path", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pts, &input_path)) - return NULL; - - // Type checks for ACIS objects - if (!_PyCheck_EDGE(input_path)) - { - PyErr_SetString(PyExc_TypeError, "Second argument (path) must be an EDGE object"); - return NULL; - } - - // The first object must be a python sequence containing SPAposition objects - PyObject *seq = PySequence_Fast(input_pts, "First argument (pts) must be a sequence of SPAposition objects, such as a list or a tuple"); - - Py_ssize_t position_vector_size = PySequence_Fast_GET_SIZE(seq); - if (position_vector_size <= 0) - { - PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); - Py_DECREF(seq); - return NULL; - } - - // It seems unnecessary to implement a SPAposition container as python itself provides a handful of containers for every purpose - SPAposition_vector _pts; - - for (Py_ssize_t i = 0; i < position_vector_size; i++) - { - PyObject *pt_temp; - pt_temp = PySequence_Fast_GET_ITEM(seq, i); - if (!_PyCheck_SPAposition(pt_temp)) - { - PyErr_SetString(PyExc_TypeError, "Sequence must contain SPAposition objects"); - Py_DECREF(seq); - return NULL; - } - _pts.push_back(*((a3dp_SPAposition *) pt_temp)->_acis_obj); - } - - API_BEGIN - - EDGE *&_path = (EDGE *&) ((a3dp_EDGE *) input_path)->base_obj._acis_obj; - - // Don't use make_sweep_path_options for now - result = api_make_sweep_path(_pts, _path); - - API_END - - // PySequence_Fast returns a new reference - Py_DECREF(seq); - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Clear SPAposition container - _pts.clear(); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -PyObject * -a3dp_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "arg1", - (char *) "arg2", - (char *) "arg3", - (char *) "arg4", - (char *) "arg5", - NULL - }; - - // Try to parse input arguments and/or keywords (hold sweep_options for now) - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO|O", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5)) - return NULL; - - /* - * IMPORTANT NOTE: This function wraps all 4 api_sweep_with_options overloads in one single Python function. - * The reason is that Python doesn't allow overloading with same function names but different signatures. - */ - - // In all overloads, first argument is always an ENTITY object - if (!_PyCheck_ENTITY(input_arg1)) - { - PyErr_SetString(PyExc_TypeError, "First argument must be an ENTITY object"); - return NULL; - } - - API_BEGIN - - ENTITY *&_ent = (ENTITY *&) ((a3dp_ENTITY *) input_arg1)->_acis_obj; - - // Check if we are using the sweep along the axis overload - if (input_arg5 != NULL) - { - if (!_PyCheck_SPAposition(input_arg2)) - { - PyErr_SetString(PyExc_TypeError, "Second argument must be a SPAposition object"); - return NULL; - } - - if (!_PyCheck_SPAvector(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Third argument must be a SPAvector object"); - return NULL; - } - - if (!_PyCheck_sweep_options(input_arg4)) - { - PyErr_SetString(PyExc_TypeError, "Fourth argument must be a sweep_options object"); - return NULL; - } - - if (!_PyCheck_BODY(input_arg5)) - { - PyErr_SetString(PyExc_TypeError, "Fifth argument must be a BODY object"); - return NULL; - } - - SPAposition *&_root = (SPAposition *&) ((a3dp_SPAposition *) input_arg2)->_acis_obj; - SPAvector *&_axis = (SPAvector *&) ((a3dp_SPAvector *) input_arg3)->_acis_obj; - sweep_options *&_opts = (sweep_options *&) ((a3dp_sweep_options *) input_arg4)->_acis_obj; - BODY *&_new_body = (BODY *&) ((a3dp_BODY *) input_arg5)->base_obj._acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, *_root, *_axis, _opts, _new_body); - - } - else - { - // We must be using the other overloads, then the 3rd argument must be a sweep_options object - if (!_PyCheck_sweep_options(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Third argument must be a sweep_options object"); - return NULL; - } - - sweep_options *&_opts = (sweep_options *&) ((a3dp_sweep_options *) input_arg3)->_acis_obj; - - // and the 4th argument must be a BODY object - if (!_PyCheck_BODY(input_arg4)) - { - PyErr_SetString(PyExc_TypeError, "Fourth argument must be a BODY object"); - return NULL; - } - - BODY *&_new_body = (BODY *&) ((a3dp_BODY *) input_arg4)->base_obj._acis_obj; - - // Check for sweeping along a given edge or a wire overload - if (_PyCheck_ENTITY(input_arg2)) - { - ENTITY *&_path = (ENTITY *&) ((a3dp_ENTITY *) input_arg2)->_acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, _path, _opts, _new_body); - } - else if (PyFloat_Check(input_arg2)) - { - // We must be using sweeping along a specified distance overload - double _distance = PyFloat_AsDouble(input_arg2); - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, _distance, _opts, _new_body); - } - else if (_PyCheck_SPAvector(input_arg2)) - { - // We must be using sweeping along a specified vector overload - SPAvector *&_vec = (SPAvector *&) ((a3dp_SPAvector *) input_arg2)->_acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, *_vec, _opts, _new_body); - } - else - { - PyErr_SetString(PyExc_TypeError, "Second argument must be an ENTITY, float or SPAvector object"); - return NULL; - } - - } - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -PyObject * -a3dp_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "entity", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_ent)) - return NULL; - - if (!_PyCheck_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - // Get the ACIS object from the user input - ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = get_owner_transf(_ent); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL, *input_ent_list = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "ent", - (char *) "face_list", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) - return NULL; - - if (!_PyCheck_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - if (!_PyCheck_ENTITY_LIST(input_ent_list)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - API_BEGIN - - // Get the ACIS objects from the user input - ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; - ENTITY_LIST *&_face_list = ((a3dp_ENTITY_LIST *) input_ent_list)->_acis_obj; - - // Call ACIS function - result = api_get_faces(_ent, *_face_list); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } - -} - -PyObject * -a3dp_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL, *input_ent_list = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "ent", - (char *) "edge_list", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) - return NULL; - - if (!_PyCheck_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - if (!_PyCheck_ENTITY_LIST(input_ent_list)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - API_BEGIN - - // Get the ACIS objects from the user input - ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; - ENTITY_LIST *&_edge_list = ((a3dp_ENTITY_LIST *) input_ent_list)->_acis_obj; - - // Call ACIS function - result = api_get_edges(_ent, *_edge_list); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } - -} diff --git a/src/acis_api.h b/src/acis_api.h deleted file mode 100644 index 0e7f970..0000000 --- a/src/acis_api.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef A3DPY_API_H -#define A3DPY_API_H - -#include -#include - -#include "acis_includes.h" -#include "acis_entity.h" -#include "acis_operators.h" -#include "acis_classes.h" -#include "acis_enums.h" -#include "acis_spa.h" -#include "utilities.h" - -#ifdef __cplusplus -extern "C" { -#endif - -PyObject *a3dp_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_stop_modeller(PyObject *self); -PyObject *a3dp_is_modeler_started(PyObject *self); -PyObject *a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_unite(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs); - -#ifdef __cplusplus -} -#endif - -#endif // !A3DPY_API_H diff --git a/src/acis_booleans.cpp b/src/acis_booleans.cpp new file mode 100644 index 0000000..930c3d8 --- /dev/null +++ b/src/acis_booleans.cpp @@ -0,0 +1,333 @@ +#include "acis_booleans.h" + + +/** + * NDBOOL_KEEP enum + */ + +static PyTypeObject + ACIS_Booleans_type_NDBOOL_KEEP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.NDBOOL_KEEP", /* tp_name */ + sizeof(ACIS_Booleans_NDBOOL_KEEP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ + }; + + +/** + * Booleans API Interface Functions + */ + +static PyObject * +ACIS_api_unite(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_ACIS_check_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_unite(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _ACIS_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +static PyObject * +ACIS_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_ACIS_check_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_intersect(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _ACIS_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +static PyObject * +ACIS_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_ACIS_check_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_subtract(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _ACIS_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +static PyObject * +ACIS_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_ACIS_check_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_imprint(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _ACIS_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +static PyObject * +ACIS_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs) +{ + /* TO-DO: Implement api_boolean_chop_body */ + return NULL; +} + +static PyMethodDef + module_methods[] = + { + { "api_unite", (PyCFunction) ACIS_api_unite, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean unite operation" }, + { "api_intersect", (PyCFunction) ACIS_api_intersect, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean intersect operation on two bodies" }, + { "api_subtract", (PyCFunction) ACIS_api_subtract, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean subtract operation" }, + { "api_imprint", (PyCFunction) ACIS_api_imprint, METH_VARARGS | METH_KEYWORDS, "Intersects two bodies and imprints the intersection graph on both bodies" }, + { "api_boolean_chop_body", (PyCFunction) ACIS_api_boolean_chop_body, METH_VARARGS | METH_KEYWORDS, "Executes simultaneous Boolean intersect and subtract operations on two bodies" }, + { NULL, NULL, 0, NULL } + }; + +// Module documentation can be accessible via __doc__ +const char *module_name = "Booleans"; +const char *module_documentation = "Contains 3D ACIS Modeler booleans API related classes and functions"; + +static struct PyModuleDef + ACIS_Booleans_module = + { + PyModuleDef_HEAD_INIT, + module_name, // name of the module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + module_methods + }; + +PyMODINIT_FUNC +PyInit_Booleans(void) +{ + PyObject *m; + + m = PyModule_Create(&ACIS_Booleans_module); + if (m == NULL) + return NULL; + + // Create a dictionary object for NDBOOL_KEEP enum + PyObject *_ndbk_dict; + _ndbk_dict = PyDict_New(); + if (_ndbk_dict != NULL) + { + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_NEITHER", PyLong_FromLong(0L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_TOOL", PyLong_FromLong(1L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BLANK", PyLong_FromLong(2L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BOTH", PyLong_FromLong(3L)); + } + + // sweep_bool_type + ACIS_Booleans_type_NDBOOL_KEEP.tp_dict = _ndbk_dict; + if (PyType_Ready(&ACIS_Booleans_type_NDBOOL_KEEP) < 0) + return NULL; + Py_INCREF(&ACIS_Booleans_type_NDBOOL_KEEP); + PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &ACIS_Booleans_type_NDBOOL_KEEP); + + return m; +} + +PyObject *_ACIS_new_NDBOOL_KEEP() +{ + return PyObject_CallObject((PyObject *) &ACIS_Booleans_type_NDBOOL_KEEP, NULL); +} + +bool _ACIS_check_NDBOOL_KEEP(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_Booleans_type_NDBOOL_KEEP; +} \ No newline at end of file diff --git a/src/acis_booleans.h b/src/acis_booleans.h new file mode 100644 index 0000000..85520ca --- /dev/null +++ b/src/acis_booleans.h @@ -0,0 +1,36 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef ACIS_BOOLEANS_H +#define ACIS_BOOLEANS_H + +#include +#include + +#include + +#include "acis_entity.h" +#include "acis_geometric_atoms.h" +#include "utilities.h" + +#include "acis_booleans_export.h" + +// Define NDBOOL_KEEP enum +typedef struct { + PyObject_HEAD +} ACIS_Booleans_NDBOOL_KEEP; + +PyObject ACIS_BOOLEANS_EXPORT *_ACIS_new_NDBOOL_KEEP(); + +bool ACIS_BOOLEANS_EXPORT _ACIS_check_NDBOOL_KEEP(PyObject *ob); + + +#endif // !ACIS_BOOLEANS_H diff --git a/src/acis_classes.cpp b/src/acis_classes.cpp deleted file mode 100644 index 049a475..0000000 --- a/src/acis_classes.cpp +++ /dev/null @@ -1,1694 +0,0 @@ -#include "acis_classes.h" - - - -/** - * SPAposition wrapper - */ - -void -a3dp_SPAposition_dealloc(a3dp_SPAposition *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_SPAposition *self; - - self = (a3dp_SPAposition *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAposition(input_x, input_y, input_z); - - return 0; -} - -PyObject * -a3dp_SPAposition_repr(a3dp_SPAposition *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAposition object (%s, %s, %s)", _x, _y, _z); -} - -PyObject * -a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->coordinate(_i)); -} - -PyObject * -a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The coordinate input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_coordinate(_i, _new_c); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAposition__x(a3dp_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -PyObject * -a3dp_SPAposition__y(a3dp_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -PyObject * -a3dp_SPAposition__z(a3dp_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -PyObject * -a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure) -{ - return a3dp_SPAposition__x(self); -} - -PyObject * -a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure) -{ - return a3dp_SPAposition__y(self); -} - -PyObject * -a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure) -{ - return a3dp_SPAposition__z(self); -} - -int -a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure) -{ - a3dp_SPAposition__set_x(self, value); - return 0; -} - -int -a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure) -{ - a3dp_SPAposition__set_y(self, value); - return 0; -} - -int -a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure) -{ - a3dp_SPAposition__set_z(self, value); - return 0; -} - -bool _PyCheck_SPAposition(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPAposition; -} - -PyObject *_PyNew_SPAposition() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPAposition, NULL); -} - -/** - * SPAvector class - */ - -void -a3dp_SPAvector_dealloc(a3dp_SPAvector *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_SPAvector *self; - - self = (a3dp_SPAvector *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAvector(input_x, input_y, input_z); - - return 0; -} - -PyObject * -a3dp_SPAvector_repr(a3dp_SPAvector *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAvector object (%s, %s, %s)", _x, _y, _z); -} - -PyObject * -a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->component(_i)); -} - -PyObject * -a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_component(_i, _new_c); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAvector__x(a3dp_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -PyObject * -a3dp_SPAvector__y(a3dp_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -PyObject * -a3dp_SPAvector__z(a3dp_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -PyObject * -a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure) -{ - return a3dp_SPAvector__x(self); -} - -PyObject * -a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure) -{ - return a3dp_SPAvector__y(self); -} - -PyObject * -a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure) -{ - return a3dp_SPAvector__z(self); -} - -int -a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure) -{ - a3dp_SPAvector__set_x(self, value); - return 0; -} - -int -a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure) -{ - a3dp_SPAvector__set_y(self, value); - return 0; -} - -int -a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure) -{ - a3dp_SPAvector__set_z(self, value); - return 0; -} - -bool _PyCheck_SPAvector(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPAvector; -} - -PyObject *_PyNew_SPAvector() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPAvector, NULL); -} - -/** - * SPAunit_vector wrapper - */ - -void -a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_SPAunit_vector *self; - - self = (a3dp_SPAunit_vector *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAunit_vector(input_x, input_y, input_z); - - return 0; -} - -PyObject * -a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAunit_vector object (%s, %s, %s)", _x, _y, _z); -} - -PyObject * -a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->component(_i)); -} - -PyObject * -a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_component(_i, _new_c); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -PyObject * -a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -PyObject * -a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -PyObject * -a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) -{ - return a3dp_SPAunitvector__x(self); -} - -PyObject * -a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) -{ - return a3dp_SPAunitvector__y(self); -} - -PyObject * -a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) -{ - return a3dp_SPAunitvector__z(self); -} - -int -a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) -{ - a3dp_SPAunitvector__set_x(self, value); - return 0; -} - -int -a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) -{ - a3dp_SPAunitvector__set_y(self, value); - return 0; -} - -int -a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) -{ - a3dp_SPAunitvector__set_z(self, value); - return 0; -} - -bool _PyCheck_SPAunit_vector(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPAunitvector; -} - -PyObject *_PyNew_SPAunit_vector() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPAunitvector, NULL); -} - -/** - * SPAmatrix wrapper - */ - -void -a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_SPAmatrix *self; - - self = (a3dp_SPAmatrix *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAmatrix(); - - return 0; -} - -PyObject * -a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg) -{ - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - // Create a new SPAvector python object - PyObject *_python_ret = _PyNew_SPAvector(); - - // Convert python input argument into a C variable - int _in_col = (int) PyLong_AsLong(arg); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((a3dp_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->column(_in_col); - - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - // Return the updated python object - return _python_ret; -} - -PyObject * -a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg) -{ - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - // Create a new SPAvector python object - PyObject *_python_ret = _PyNew_SPAvector(); - - // Convert python input argument into a C variable - int _in_row = (int) PyLong_AsLong(arg); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((a3dp_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->row(_in_row); - - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - // Return the updated python object - return _python_ret; -} - -PyObject * -a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self) -{ - // Create a new SPAmatrix python object - PyObject *_python_ret = _PyNew_SPAmatrix(); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((a3dp_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->inverse(); - - // Return the updated python object - return _python_ret; -} - -PyObject * -a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self) -{ - // Create a new SPAmatrix python object - PyObject *_python_ret = _PyNew_SPAmatrix(); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((a3dp_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->transpose(); - - // Return the updated python object - return _python_ret; -} - -PyObject * -a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self) -{ - // Execute the ACIS function and return the value as a python object - return PyFloat_FromDouble(self->_acis_obj->determinant()); -} - -PyObject * -a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - int input_row, input_col; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "row", - (char *) "col", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_row, &input_col)) - return NULL; - - // Execute the ACIS function and return the value as a python object - return PyFloat_FromDouble(self->_acis_obj->element(input_row, input_col)); -} - -PyObject * -a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - int input_row, input_col; - double input_new_e; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "row", - (char *) "col", - (char *) "new_e", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iid", kwlist, &input_row, &input_col, &input_new_e)) - return NULL; - - // Execute the ACIS function - self->_acis_obj->set_element(input_row, input_col, input_new_e); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self) -{ - logical _ret_val = self->_acis_obj->is_identity(); - - if (_ret_val) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -bool _PyCheck_SPAmatrix(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPAmatrix; -} - -PyObject *_PyNew_SPAmatrix() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPAmatrix, NULL); -} - -/** - * SPAtransf wrapper - */ - -void -a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_SPAtransf *self; - - self = (a3dp_SPAtransf *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAtransf(); - - return 0; -} - -PyObject * -a3dp_SPAtransf__affine(a3dp_SPAtransf *self) -{ - PyObject *_ret = _PyNew_SPAmatrix(); - - *((a3dp_SPAmatrix *) _ret)->_acis_obj = self->_acis_obj->affine(); - - return _ret; -} - -PyObject * -a3dp_SPAtransf__inverse(a3dp_SPAtransf *self) -{ - PyObject *_ret = _PyNew_SPAtransf(); - - *((a3dp_SPAtransf *) _ret)->_acis_obj = self->_acis_obj->inverse(); - - return _ret; -} - -PyObject * -a3dp_SPAtransf__translation(a3dp_SPAtransf *self) -{ - PyObject *_ret = _PyNew_SPAvector(); - - *((a3dp_SPAvector *) _ret)->_acis_obj = self->_acis_obj->translation(); - - return _ret; -} - -PyObject * -a3dp_SPAtransf__identity(a3dp_SPAtransf *self) -{ - logical _check = self->_acis_obj->identity(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -PyObject * -a3dp_SPAtransf__reflect(a3dp_SPAtransf *self) -{ - logical _check = self->_acis_obj->reflect(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -PyObject * -a3dp_SPAtransf__rotate(a3dp_SPAtransf *self) -{ - logical _check = self->_acis_obj->rotate(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -PyObject * -a3dp_SPAtransf__scaling(a3dp_SPAtransf *self) -{ - return PyFloat_FromDouble(self->_acis_obj->scaling()); -} - -PyObject * -a3dp_SPAtransf__shear(a3dp_SPAtransf *self) -{ - logical _check = self->_acis_obj->shear(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - - -bool _PyCheck_SPAtransf(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPAtransf; -} - -PyObject *_PyNew_SPAtransf() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPAtransf, NULL); -} - -/** - * SPApar_pos wrapper - */ - -void -a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_SPApar_pos *self; - - self = (a3dp_SPApar_pos *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPApar_pos(); - - return 0; -} - -PyObject * -a3dp_SPAparpos_repr(a3dp_SPApar_pos *self) -{ - double u = self->_acis_obj->u; double v = self->_acis_obj->v; - - char *_u = PyOS_double_to_string(u, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_u) - return PyErr_NoMemory(); - - char *_v = PyOS_double_to_string(v, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_v) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPApar_pos object (%s, %s)", _u, _v); -} - -PyObject * -a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->u); -} - -int -a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) -{ - self->_acis_obj->u = PyFloat_AsDouble(value); - return 0; -} - -PyObject * -a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->v); -} - -int -a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) -{ - self->_acis_obj->v = PyFloat_AsDouble(value); - return 0; -} - -bool _PyCheck_SPApar_pos(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPAparpos; -} - -PyObject *_PyNew_SPApar_pos() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPAparpos, NULL); -} - -/** - * SPApar_vec wrapper - */ - -void -a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_SPApar_vec *self; - - self = (a3dp_SPApar_vec *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPApar_vec(); - - return 0; -} - -PyObject * -a3dp_SPAparvec_repr(a3dp_SPApar_vec *self) -{ - double du = self->_acis_obj->du; double dv = self->_acis_obj->dv; - - char *_du = PyOS_double_to_string(du, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_du) - return PyErr_NoMemory(); - - char *_dv = PyOS_double_to_string(dv, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_dv) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPApar_vec object (%s, %s)", _du, _dv); -} - -PyObject * -a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->du); -} - -int -a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) -{ - self->_acis_obj->du = PyFloat_AsDouble(value); - return 0; -} - -PyObject * -a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->dv); -} - -int -a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) -{ - self->_acis_obj->dv = PyFloat_AsDouble(value); - return 0; -} - -bool _PyCheck_SPApar_vec(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPAparvec; -} - -PyObject *_PyNew_SPApar_vec() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPAparvec, NULL); -} - - -/** - * FileInfo class - */ - -void -a3dp_FileInfo_dealloc(a3dp_FileInfo *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object itself - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_FileInfo *self; - - self = (a3dp_FileInfo *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - self->_acis_obj = ACIS_NEW FileInfo(); - return 0; -} - -PyObject * -a3dp_FileInfo__acis_version(a3dp_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->acis_version()); -} - -PyObject * -a3dp_FileInfo__date(a3dp_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->date()); -} - -PyObject * -a3dp_FileInfo__file_version(a3dp_FileInfo *self) -{ - return PyLong_FromLong((long) self->_acis_obj->file_version()); -} - -PyObject * -a3dp_FileInfo__product_id(a3dp_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->product_id()); -} - -PyObject * -a3dp_FileInfo__reset(a3dp_FileInfo *self) -{ - self->_acis_obj->reset(); - Py_RETURN_NONE; -} - -PyObject * -a3dp_FileInfo__reset_vars(a3dp_FileInfo *self) -{ - self->_acis_obj->reset_vars(); - Py_RETURN_NONE; -} - -PyObject * -a3dp_FileInfo__restore(a3dp_FileInfo *self) -{ - self->_acis_obj->restore(); - Py_RETURN_NONE; -} - -PyObject * -a3dp_FileInfo__save(a3dp_FileInfo *self) -{ - self->_acis_obj->save(); - Py_RETURN_NONE; -} - -PyObject * -a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - unsigned long input_field; - PyObject *input_file = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "field", - (char *) "file", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "lO", kwlist, &input_field, &input_file)) - return NULL; - - // Check if the user input is a FileInfo object - if (_PyCheck_FileInfo(input_file)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - // Convert PyObject to ENTITY_LIST - FileInfo *_file = ((a3dp_FileInfo *) input_file)->_acis_obj; - - // Execute ACIS function - self->_acis_obj->set_masked(input_field, *_file); - - // Return None - Py_RETURN_NONE; -} - -PyObject * -a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - const char *input_id = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "id", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &input_id)) - return NULL; - - self->_acis_obj->set_product_id(input_id); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - double input_count; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "count", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_count)) - return NULL; - - self->_acis_obj->set_units(input_count); - - Py_RETURN_NONE; -} - -PyObject * -a3dp_FileInfo__tol_abs(a3dp_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->tol_abs()); -} - -PyObject * -a3dp_FileInfo__tol_nor(a3dp_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->tol_nor()); -} - -PyObject * -a3dp_FileInfo__units(a3dp_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->units()); -} - -PyObject * -a3dp_FileInfo__valid(a3dp_FileInfo *self) -{ - self->_acis_obj->valid(); - Py_RETURN_NONE; -} - -bool -_PyCheck_FileInfo(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_FileInfo; -} - -void -a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_make_sweep_path_options *self; - - self = (a3dp_make_sweep_path_options *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW make_sweep_path_options(); - - return 0; -} - -void -a3dp_sweepoptions_dealloc(a3dp_sweep_options *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - Py_TYPE(self)->tp_free((PyObject *) self); -} - -PyObject * -a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - a3dp_sweep_options *self; - - self = (a3dp_sweep_options *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -int -a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW sweep_options(); - - return 0; -} - -PyObject * -a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) -{ - // Just a testing... - self->_acis_obj->set_bool_type(KEEP_BOTH); - - Py_RETURN_NONE; -} - - -PyObject * -_PyNew_make_sweep_path_options() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_make_sweep_path_options, NULL); -} - -bool -_PyCheck_make_sweep_path_options(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_make_sweep_path_options; -} - -PyObject * -_PyNew_sweep_options() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_sweep_options, NULL); -} - -bool -_PyCheck_sweep_options(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_sweep_options; -} diff --git a/src/acis_classes.h b/src/acis_classes.h deleted file mode 100644 index fff4746..0000000 --- a/src/acis_classes.h +++ /dev/null @@ -1,841 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef A3DPY_CLASSES_H -#define A3DPY_CLASSES_H - -#include -#include - -#include "acis_includes.h" -#include "utilities.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -// Define SPAposition -typedef struct -{ - PyObject_HEAD - SPAposition *_acis_obj; -} a3dp_SPAposition; - -void a3dp_SPAposition_dealloc(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAposition_repr(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__x(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition__y(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition__z(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure); -PyObject *a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure); -PyObject *a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure); -int a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure); -int a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure); -int a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAposition[] = - { - { (char *) "x_value", (getter) a3dp_SPAposition_x_getter, (setter) a3dp_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, - { (char *) "y_value", (getter) a3dp_SPAposition_y_getter, (setter) a3dp_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, - { (char *) "z_value", (getter) a3dp_SPAposition_z_getter, (setter) a3dp_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_SPAposition[] = - { - { "coordinate", (PyCFunction) a3dp_SPAposition__coordinate, METH_O, "Returns the i-th component value" }, - { "set_coordinate", (PyCFunction) a3dp_SPAposition__set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, - { "set_x", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the x-coordinate value" }, - { "set_y", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the y-coordinate value" }, - { "set_z", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the z-coordinate value" }, - { "x", (PyCFunction) a3dp_SPAposition__x, METH_NOARGS, "Returns the x-coordinate value" }, - { "y", (PyCFunction) a3dp_SPAposition__y, METH_NOARGS, "Returns the y-coordinate value" }, - { "z", (PyCFunction) a3dp_SPAposition__z, METH_NOARGS, "Returns the z-coordinate value" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAposition = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAposition", /* tp_name */ - sizeof(a3dp_SPAposition), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAposition_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAposition_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAposition_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAposition, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAposition, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAposition_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAposition_new, /* tp_new */ - }; - - -PyObject *_PyNew_SPAposition(); - -bool _PyCheck_SPAposition(PyObject *ob); - -// Define SPAvector -typedef struct -{ - PyObject_HEAD - SPAvector *_acis_obj; -} a3dp_SPAvector; - -void a3dp_SPAvector_dealloc(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAvector_repr(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__x(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector__y(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector__z(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure); -int a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure); -int a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure); -int a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAvector[] = - { - { (char *) "x_value", (getter) a3dp_SPAvector_x_getter, (setter) a3dp_SPAvector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) a3dp_SPAvector_y_getter, (setter) a3dp_SPAvector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) a3dp_SPAvector_z_getter, (setter) a3dp_SPAvector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_SPAvector[] = - { - { "component", (PyCFunction) a3dp_SPAvector__component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) a3dp_SPAvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) a3dp_SPAvector__x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) a3dp_SPAvector__y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) a3dp_SPAvector__z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAvector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAvector", /* tp_name */ - sizeof(a3dp_SPAvector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAvector_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAvector_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAvector_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAvector, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAvector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAvector_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAvector_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAvector(); - -bool _PyCheck_SPAvector(PyObject *ob); - -// Define SPAunit_vector -typedef struct -{ - PyObject_HEAD - SPAunit_vector *_acis_obj; -} a3dp_SPAunit_vector; - -void a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -int a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -int a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -int a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAunit_vector[] = - { - { (char *) "x_value", (getter) a3dp_SPAunitvector_x_getter, (setter) a3dp_SPAunitvector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) a3dp_SPAunitvector_y_getter, (setter) a3dp_SPAunitvector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) a3dp_SPAunitvector_z_getter, (setter) a3dp_SPAunitvector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_SPAunit_vector[] = - { - { "component", (PyCFunction) a3dp_SPAunitvector__component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) a3dp_SPAunitvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) a3dp_SPAunitvector__x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) a3dp_SPAunitvector__y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) a3dp_SPAunitvector__z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAunitvector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAunit_vector", /* tp_name */ - sizeof(a3dp_SPAunit_vector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAunitvector_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAunitvector_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAunitvector_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAunit_vector, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAunit_vector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAunitvector_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAunitvector_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAunit_vector(); - -bool _PyCheck_SPAunit_vector(PyObject *ob); - -// Define SPAmatrix -typedef struct -{ - PyObject_HEAD - SPAmatrix *_acis_obj; -} a3dp_SPAmatrix; - -void a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg); -PyObject *a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg); -PyObject *a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self); - -static PyMethodDef - a3dp_methods_SPAmatrix[] = - { - { "column", (PyCFunction) a3dp_SPAmatrix__column, METH_O, "Extracts a column from this matrix" }, - { "row", (PyCFunction) a3dp_SPAmatrix__row, METH_O, "Extracts a row from this matrix" }, - { "element", (PyCFunction) a3dp_SPAmatrix__element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, - { "set_element", (PyCFunction) a3dp_SPAmatrix__set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, - { "determinant", (PyCFunction) a3dp_SPAmatrix__determinant, METH_NOARGS, "Returns the determinant of this matrix" }, - { "transpose", (PyCFunction) a3dp_SPAmatrix__transpose, METH_NOARGS, "Returns a transpose of this matrix" }, - { "inverse", (PyCFunction) a3dp_SPAmatrix__inverse, METH_NOARGS, "Returns the inverse of this matrix" }, - { "is_identity", (PyCFunction) a3dp_SPAmatrix__is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAmatrix = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAmatrix", /* tp_name */ - sizeof(a3dp_SPAmatrix), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAmatrix_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAmatrix, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAmatrix_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAmatrix_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAmatrix(); - -bool _PyCheck_SPAmatrix(PyObject *ob); - -// Define SPAtransf -typedef struct -{ - PyObject_HEAD - SPAtransf *_acis_obj; -} a3dp_SPAtransf; - -void a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAtransf__affine(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__inverse(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__translation(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__identity(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__reflect(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__rotate(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__scaling(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__shear(a3dp_SPAtransf *self); - -static PyMethodDef - a3dp_methods_SPAtransf[] = - { - { "affine", (PyCFunction) a3dp_SPAtransf__affine, METH_NOARGS, "Returns the affine portion of the transformation" }, - { "inverse", (PyCFunction) a3dp_SPAtransf__inverse, METH_NOARGS, "Returns the inverse transformation" }, - { "translation", (PyCFunction) a3dp_SPAtransf__translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, - { "identity", (PyCFunction) a3dp_SPAtransf__identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, - { "reflect", (PyCFunction) a3dp_SPAtransf__reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, - { "rotate", (PyCFunction) a3dp_SPAtransf__rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, - { "scaling", (PyCFunction) a3dp_SPAtransf__scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, - { "shear", (PyCFunction) a3dp_SPAtransf__shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAtransf = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(a3dp_SPAtransf), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAtransf_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAtransf represents a general 3D affine transformation", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAtransf, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAtransf_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAtransf_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAtransf(); - -bool _PyCheck_SPAtransf(PyObject *ob); - -// Define SPApar_pos -typedef struct -{ - PyObject_HEAD - SPApar_pos *_acis_obj; -} a3dp_SPApar_pos; - -void a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self); -PyObject *a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAparpos_repr(a3dp_SPApar_pos *self); -PyObject *a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); -int a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); -PyObject *a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); -int a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAparpos[] = - { - { (char *) "u", (getter) a3dp_SPAparpos_u_getter, (setter) a3dp_SPAparpos_u_setter, (char *) "value of the u parameter", NULL }, - { (char *) "v", (getter) a3dp_SPAparpos_v_getter, (setter) a3dp_SPAparpos_v_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAparpos = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(a3dp_SPApar_pos), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAparpos_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAparpos_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAparpos_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAparpos, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAparpos_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAparpos_new, /* tp_new */ - }; - -PyObject *_PyNew_SPApar_pos(); - -bool _PyCheck_SPApar_pos(PyObject *ob); - -// Define SPApar_vec -typedef struct -{ - PyObject_HEAD - SPApar_vec *_acis_obj; -} a3dp_SPApar_vec; - -void a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self); -PyObject *a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAparvec_repr(a3dp_SPApar_vec *self); -PyObject *a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); -int a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); -PyObject *a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); -int a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAparvec[] = - { - { (char *) "du", (getter) a3dp_SPAparvec_du_getter, (setter) a3dp_SPAparvec_du_setter, (char *) "value of the u parameter", NULL }, - { (char *) "dv", (getter) a3dp_SPAparvec_dv_getter, (setter) a3dp_SPAparvec_dv_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAparvec = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPApar_vec", /* tp_name */ - sizeof(a3dp_SPApar_vec), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAparvec_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAparvec_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAparvec_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAparvec, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAparvec_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAparvec_new, /* tp_new */ - }; - -PyObject *_PyNew_SPApar_vec(); - -bool _PyCheck_SPApar_vec(PyObject *ob); - -// Define FileInfo -typedef struct -{ - PyObject_HEAD - FileInfo *_acis_obj; -} a3dp_FileInfo; - -void a3dp_FileInfo_dealloc(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__acis_version(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__date(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__file_version(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__product_id(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__reset(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__reset_vars(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__restore(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__save(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__tol_abs(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__tol_nor(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__units(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__valid(a3dp_FileInfo *self); - -static PyMemberDef - a3dp_members_FileInfo[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_FileInfo[] = - { - { "acis_version", (PyCFunction) a3dp_FileInfo__acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, - { "date", (PyCFunction) a3dp_FileInfo__date, METH_NOARGS, "Returns the date on the save file" }, - { "file_version", (PyCFunction) a3dp_FileInfo__file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, - { "product_id", (PyCFunction) a3dp_FileInfo__product_id, METH_NOARGS, "Returns the ID of the product" }, - { "reset", (PyCFunction) a3dp_FileInfo__reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, - { "reset_vars", (PyCFunction) a3dp_FileInfo__reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, - { "restore", (PyCFunction) a3dp_FileInfo__restore, METH_NOARGS, "Restores the file information from a save file" }, - { "save", (PyCFunction) a3dp_FileInfo__save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, - //{ "set_masked", (PyCFunction)a3dp_FileInfo__set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, - { "set_product_id", (PyCFunction) a3dp_FileInfo__set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, - { "set_units", (PyCFunction) a3dp_FileInfo__set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, - { "tol_abs", (PyCFunction) a3dp_FileInfo__tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, - { "tol_nor", (PyCFunction) a3dp_FileInfo__tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, - { "units", (PyCFunction) a3dp_FileInfo__units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, - { "valid", (PyCFunction) a3dp_FileInfo__valid, METH_NOARGS, "Checks the values of the units and product id" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_FileInfo = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FileInfo", /* tp_name */ - sizeof(a3dp_FileInfo), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_FileInfo_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "FileInfo object contains additional required save file header information", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_FileInfo, /* tp_methods */ - a3dp_members_FileInfo, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_FileInfo_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_FileInfo_new, /* tp_new */ - }; - -bool _PyCheck_FileInfo(PyObject *ob); - -// Define sweep_options -typedef struct -{ - PyObject_HEAD - sweep_options *_acis_obj; -} a3dp_sweep_options; - -void a3dp_sweepoptions_dealloc(a3dp_sweep_options *self); -PyObject *a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); - -static PyMethodDef - a3dp_methods_sweepoptions[] = - { - { "set_bool_type", (PyCFunction) a3dp_sweepoptions__set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_sweep_options = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_options", /* tp_name */ - sizeof(a3dp_sweep_options), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_sweepoptions_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_sweepoptions, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_sweepoptions_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_sweepoptions_new, /* tp_new */ - }; - -PyObject *_PyNew_sweep_options(); -bool _PyCheck_sweep_options(PyObject *ob); - -// Define make_sweep_path_options -typedef struct -{ - PyObject_HEAD - make_sweep_path_options *_acis_obj; -} a3dp_make_sweep_path_options; - -void a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self); -PyObject *a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs); - -static PyTypeObject - a3dp_type_make_sweep_path_options = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.make_sweep_path_options", /* tp_name */ - sizeof(a3dp_make_sweep_path_options), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_makesweeppathoptions_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_makesweeppathoptions_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_makesweeppathoptions_new, /* tp_new */ - }; - -PyObject *_PyNew_make_sweep_path_options(); -bool _PyCheck_make_sweep_path_options(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !A3DPY_CLASSES_H diff --git a/src/acis_entity.cpp b/src/acis_entity.cpp index e9f61a5..677e3cf 100644 --- a/src/acis_entity.cpp +++ b/src/acis_entity.cpp @@ -2,11 +2,11 @@ /** - * ENTITY class + * 3D ACIS Modeler - ENTITY wrapper */ int -a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg) +ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg) { // Use Py_VISIT macro for PyObject-type variables Py_VISIT(self->attrib_name); @@ -16,7 +16,7 @@ a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg) } int -a3dp_ENTITY_clear(a3dp_ENTITY *self) +ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self) { // Set ACIS object to NULL to allow it automatically deleted by ACIS memory manager //self->_acis_obj = NULL; @@ -29,14 +29,14 @@ a3dp_ENTITY_clear(a3dp_ENTITY *self) } void -a3dp_ENTITY_dealloc(a3dp_ENTITY *self) +ACIS_Entity_dealloc_ENTITY(ACIS_Entity_ENTITY *self) { - a3dp_ENTITY_clear(self); + ACIS_Entity_clear_ENTITY(self); Py_TYPE(self)->tp_free((PyObject *) self); } PyObject * -a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started if (!is_modeler_started()) @@ -45,9 +45,9 @@ a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return NULL; } - a3dp_ENTITY *self; + ACIS_Entity_ENTITY *self; - self = (a3dp_ENTITY *) type->tp_alloc(type, 0); + self = (ACIS_Entity_ENTITY *) type->tp_alloc(type, 0); if (self != NULL) { self->attrib_name = PyUnicode_FromString(""); @@ -72,13 +72,13 @@ a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } int -a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs) +ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwargs) { // PyObject *input_name = NULL; // PyObject *input_id = NULL; // PyObject *tmp; // -// char *kwlist[] = +// static char *kwlist[] = // { // (char *) "name", // (char *) "id", @@ -128,7 +128,7 @@ a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs) } PyObject * -a3dp_ENTITY_repr(a3dp_ENTITY *self) +ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self) { const char *_name = PyUnicode_AsUTF8(self->attrib_name); int _id = (int) PyLong_AsLong(self->attrib_object_id); @@ -136,7 +136,7 @@ a3dp_ENTITY_repr(a3dp_ENTITY *self) } PyObject * -a3dp_ENTITY_str(a3dp_ENTITY *self) +ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self) { const char *acis_obj_status = NULL; if (self->_acis_obj == NULL) @@ -148,14 +148,14 @@ a3dp_ENTITY_str(a3dp_ENTITY *self) } PyObject * -a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) +ACIS_Entity_method_ENTITY_get_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_name); return self->attrib_name; } int -a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) +ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) { @@ -188,21 +188,21 @@ a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) } PyObject * -a3dp_ENTITY_type_name(PyObject *self) +ACIS_Entity_method_ENTITY_type_name(PyObject *self) { - const char *_retval = ((a3dp_ENTITY *)self)->_acis_obj->type_name(); + const char *_retval = ((ACIS_Entity_ENTITY *)self)->_acis_obj->type_name(); return PyUnicode_FromString(_retval); } PyObject * -a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) +ACIS_Entity_method_ENTITY_get_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_object_id); return self->attrib_object_id; } int -a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) +ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) { @@ -239,29 +239,29 @@ a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) /** - * BODY class + * 3D ACIS Modeler - BODY wrapper */ -int -a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_BODY(ACIS_Entity_BODY *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_BODY_repr(a3dp_BODY *self) +static PyObject * +ACIS_Entity_repr_BODY(ACIS_Entity_BODY *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("BODY object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_BODY_str(a3dp_BODY *self) +static PyObject * +ACIS_Entity_str_BODY(ACIS_Entity_BODY *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -272,31 +272,92 @@ a3dp_BODY_str(a3dp_BODY *self) return PyUnicode_FromFormat("BODY object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_BODY[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_BODY[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_BODY[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_BODY = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.BODY", /* tp_name */ + sizeof(ACIS_Entity_BODY), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_BODY, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_BODY, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS BODY class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_BODY, /* tp_methods */ + ACIS_Entity_members_BODY, /* tp_members */ + ACIS_Entity_getseters_BODY, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_BODY, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + /** - * FACE class + * 3D ACIS Modeler - FACE wrapper */ -int -a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_FACE(ACIS_Entity_FACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_FACE_repr(a3dp_FACE *self) +static PyObject * +ACIS_Entity_repr_FACE(ACIS_Entity_FACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("FACE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_FACE_str(a3dp_FACE *self) +static PyObject * +ACIS_Entity_str_FACE(ACIS_Entity_FACE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -307,8 +368,8 @@ a3dp_FACE_str(a3dp_FACE *self) return PyUnicode_FromFormat("FACE object (%s)", acis_obj_status); } -PyObject * -a3dp_FACE__sense(a3dp_FACE *self) +static PyObject * +ACIS_Entity_method_FACE_sense(ACIS_Entity_FACE *self) { logical _revbit; _revbit = ((FACE *) self->base_obj._acis_obj)->sense(); @@ -320,40 +381,103 @@ a3dp_FACE__sense(a3dp_FACE *self) Py_RETURN_FALSE; } -PyObject * -a3dp_FACE__geometry(a3dp_FACE *self) +static PyObject * +ACIS_Entity_method_FACE_geometry(ACIS_Entity_FACE *self) { - PyObject *_retobj = _PyNew_SURFACE(); + PyObject *_retobj = _ACIS_new_SURFACE(); // Store everything as ENTITY - ((a3dp_SURFACE *) _retobj)->base_obj._acis_obj = (ENTITY *) ((FACE *) self->base_obj._acis_obj)->geometry(); + ((ACIS_Entity_SURFACE *) _retobj)->base_obj._acis_obj = (ENTITY *) ((FACE *) self->base_obj._acis_obj)->geometry(); return _retobj; } +static PyGetSetDef + ACIS_Entity_getseters_FACE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_FACE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_FACE[] = + { + { "sense", (PyCFunction) ACIS_Entity_method_FACE_sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, + { "geometry", (PyCFunction) ACIS_Entity_method_FACE_geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_FACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FACE", /* tp_name */ + sizeof(ACIS_Entity_FACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_FACE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_FACE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS FACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_FACE, /* tp_methods */ + ACIS_Entity_members_FACE, /* tp_members */ + ACIS_Entity_getseters_FACE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_FACE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + /** - * EDGE class + * 3D ACIS Modeler - EDGE wrapper */ -int -a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_EDGE(ACIS_Entity_EDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_EDGE_repr(a3dp_EDGE *self) +static PyObject * +ACIS_Entity_repr_EDGE(ACIS_Entity_EDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("EDGE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_EDGE_str(a3dp_EDGE *self) +static PyObject * +ACIS_Entity_str_EDGE(ACIS_Entity_EDGE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -364,31 +488,92 @@ a3dp_EDGE_str(a3dp_EDGE *self) return PyUnicode_FromFormat("EDGE object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_EDGE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_EDGE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_EDGE[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_EDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.EDGE", /* tp_name */ + sizeof(ACIS_Entity_EDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_EDGE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_EDGE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS EDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_EDGE, /* tp_methods */ + ACIS_Entity_members_EDGE, /* tp_members */ + ACIS_Entity_getseters_EDGE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_EDGE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + /** - * WIRE class + * 3D ACIS Modeler - WIRE wrapper */ -int -a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_WIRE(ACIS_Entity_WIRE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_WIRE_repr(a3dp_WIRE *self) +static PyObject * +ACIS_Entity_repr_WIRE(ACIS_Entity_WIRE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("WIRE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_WIRE_str(a3dp_WIRE *self) +static PyObject * +ACIS_Entity_str_WIRE(ACIS_Entity_WIRE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -399,30 +584,92 @@ a3dp_WIRE_str(a3dp_WIRE *self) return PyUnicode_FromFormat("WIRE object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_WIRE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_WIRE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_WIRE[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_WIRE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.WIRE", /* tp_name */ + sizeof(ACIS_Entity_WIRE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_WIRE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_WIRE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS WIRE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_WIRE, /* tp_methods */ + ACIS_Entity_members_WIRE, /* tp_members */ + ACIS_Entity_getseters_WIRE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_WIRE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * LUMP class + * 3D ACIS Modeler - LUMP wrapper */ -int -a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_LUMP(ACIS_Entity_LUMP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_LUMP_repr(a3dp_LUMP *self) +static PyObject * +ACIS_Entity_repr_LUMP(ACIS_Entity_LUMP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("LUMP object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_LUMP_str(a3dp_LUMP *self) +static PyObject * +ACIS_Entity_str_LUMP(ACIS_Entity_LUMP *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -433,30 +680,92 @@ a3dp_LUMP_str(a3dp_LUMP *self) return PyUnicode_FromFormat("LUMP object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_LUMP[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_LUMP[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_LUMP[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_LUMP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LUMP", /* tp_name */ + sizeof(ACIS_Entity_LUMP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_LUMP, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_LUMP, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LUMP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_LUMP, /* tp_methods */ + ACIS_Entity_members_LUMP, /* tp_members */ + ACIS_Entity_getseters_LUMP, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_LUMP, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * SHELL class + * 3D ACIS Modeler - SHELL wrapper */ -int -a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_SHELL(ACIS_Entity_SHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_SHELL_repr(a3dp_SHELL *self) +static PyObject * +ACIS_Entity_repr_SHELL(ACIS_Entity_SHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SHELL object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_SHELL_str(a3dp_SHELL *self) +static PyObject * +ACIS_Entity_str_SHELL(ACIS_Entity_SHELL *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -467,30 +776,92 @@ a3dp_SHELL_str(a3dp_SHELL *self) return PyUnicode_FromFormat("SHELL object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_SHELL[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_SHELL[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_SHELL[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_SHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SHELL", /* tp_name */ + sizeof(ACIS_Entity_SHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_SHELL, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_SHELL, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_SHELL, /* tp_methods */ + ACIS_Entity_members_SHELL, /* tp_members */ + ACIS_Entity_getseters_SHELL, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_SHELL, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * SUBSHELL class + * 3D ACIS Modeler - SUBSHELL wrapper */ -int -a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_SUBSHELL(ACIS_Entity_SUBSHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self) +static PyObject * +ACIS_Entity_repr_SUBSHELL(ACIS_Entity_SUBSHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SUBSHELL object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_SUBSHELL_str(a3dp_SUBSHELL *self) +static PyObject * +ACIS_Entity_str_SUBSHELL(ACIS_Entity_SUBSHELL *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -501,30 +872,92 @@ a3dp_SUBSHELL_str(a3dp_SUBSHELL *self) return PyUnicode_FromFormat("SUBSHELL object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_SUBSHELL[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_SUBSHELL[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_SUBSHELL[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_SUBSHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SUBSHELL", /* tp_name */ + sizeof(ACIS_Entity_SUBSHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_SUBSHELL, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_SUBSHELL, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SUBSHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_SUBSHELL, /* tp_methods */ + ACIS_Entity_members_SUBSHELL, /* tp_members */ + ACIS_Entity_getseters_SUBSHELL, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_SUBSHELL, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * COEDGE class + * 3D ACIS Modeler - COEDGE wrapper */ -int -a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_COEDGE(ACIS_Entity_COEDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_COEDGE_repr(a3dp_COEDGE *self) +static PyObject * +ACIS_Entity_repr_COEDGE(ACIS_Entity_COEDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("COEDGE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_COEDGE_str(a3dp_COEDGE *self) +static PyObject * +ACIS_Entity_str_COEDGE(ACIS_Entity_COEDGE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -535,31 +968,92 @@ a3dp_COEDGE_str(a3dp_COEDGE *self) return PyUnicode_FromFormat("COEDGE object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_COEDGE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_COEDGE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_COEDGE[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_COEDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.COEDGE", /* tp_name */ + sizeof(ACIS_Entity_COEDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_COEDGE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_COEDGE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS COEDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_COEDGE, /* tp_methods */ + ACIS_Entity_members_COEDGE, /* tp_members */ + ACIS_Entity_getseters_COEDGE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_COEDGE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + /** - * LOOP class + * 3D ACIS Modeler - LOOP wrapper */ -int -a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_LOOP(ACIS_Entity_LOOP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_LOOP_repr(a3dp_LOOP *self) +static PyObject * +ACIS_Entity_repr_LOOP(ACIS_Entity_LOOP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("LOOP object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_LOOP_str(a3dp_LOOP *self) +static PyObject * +ACIS_Entity_str_LOOP(ACIS_Entity_LOOP *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -570,30 +1064,92 @@ a3dp_LOOP_str(a3dp_LOOP *self) return PyUnicode_FromFormat("LOOP object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_LOOP[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_LOOP[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_LOOP[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_LOOP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LOOP", /* tp_name */ + sizeof(ACIS_Entity_LOOP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_LOOP, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_LOOP, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LOOP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_LOOP, /* tp_methods */ + ACIS_Entity_members_LOOP, /* tp_members */ + ACIS_Entity_getseters_LOOP, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_LOOP, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * VERTEX class + * 3D ACIS Modeler - VERTEX wrapper */ -int -a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_VERTEX(ACIS_Entity_VERTEX *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_VERTEX_repr(a3dp_VERTEX *self) +static PyObject * +ACIS_Entity_repr_VERTEX(ACIS_Entity_VERTEX *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("VERTEX object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_VERTEX_str(a3dp_VERTEX *self) +static PyObject * +ACIS_Entity_str_VERTEX(ACIS_Entity_VERTEX *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -604,30 +1160,92 @@ a3dp_VERTEX_str(a3dp_VERTEX *self) return PyUnicode_FromFormat("VERTEX object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_VERTEX[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_VERTEX[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_VERTEX[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_VERTEX = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.VERTEX", /* tp_name */ + sizeof(ACIS_Entity_VERTEX), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_VERTEX, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_VERTEX, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS VERTEX class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_VERTEX, /* tp_methods */ + ACIS_Entity_members_VERTEX, /* tp_members */ + ACIS_Entity_getseters_VERTEX, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_VERTEX, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * SURFACE class + * 3D ACIS Modeler - SURFACE wrapper */ -int -a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_SURFACE(ACIS_Entity_SURFACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_SURFACE_repr(a3dp_SURFACE *self) +static PyObject * +ACIS_Entity_repr_SURFACE(ACIS_Entity_SURFACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SURFACE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_SURFACE_str(a3dp_SURFACE *self) +static PyObject * +ACIS_Entity_str_SURFACE(ACIS_Entity_SURFACE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -638,21 +1256,21 @@ a3dp_SURFACE_str(a3dp_SURFACE *self) return PyUnicode_FromFormat("SURFACE object (%s)", acis_obj_status); } -PyObject * -a3dp_SURFACE__equation(a3dp_SURFACE *self) +static PyObject * +ACIS_Entity_method_SURFACE_equation(ACIS_Entity_SURFACE *self) { - PyObject *_retobj = _PyNew_surface(); - *((a3dp_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->equation(); + PyObject *_retobj = _ACIS_new_surface(); + *((ACIS_Entity_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->equation(); return _retobj; } -PyObject * -a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) +static PyObject * +ACIS_Entity_method_SURFACE_trans_surface(ACIS_Entity_SURFACE *self, PyObject *args, PyObject *kwargs) { PyObject *input_t = NULL, *input_reverse = NULL; // List of keyword arguments that this function can take - char *kwlist[] = + static char *kwlist[] = { (char *) "t", (char *) "reverse", @@ -667,13 +1285,13 @@ a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs if (input_t != NULL) { // Validate input - if (!_PyCheck_SPAtransf(input_t)) + if (!_ACIS_check_SPAtransf(input_t)) { PyErr_SetString(PyExc_TypeError, "The first argument (t) must be a SPAtransf object"); return NULL; } - _t = *((a3dp_SPAtransf *) input_t)->_acis_obj; + _t = *((ACIS_GeometricAtoms_SPAtransf *) input_t)->_acis_obj; } logical _reverse = FALSE; @@ -683,35 +1301,99 @@ a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs _reverse = (_py_inp_reverse == 0) ? FALSE : TRUE; } - PyObject *_retobj = _PyNew_surface(); - ((a3dp_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->trans_surface(_t, _reverse); + PyObject *_retobj = _ACIS_new_surface(); + ((ACIS_Entity_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->trans_surface(_t, _reverse); return _retobj; } +static PyGetSetDef + ACIS_Entity_getseters_SURFACE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_SURFACE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_SURFACE[] = + { + { "equation", (PyCFunction) ACIS_Entity_method_SURFACE_equation, METH_NOARGS, "Returns the equation of this SURFACE" }, + { "trans_surface", (PyCFunction) ACIS_Entity_method_SURFACE_trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_SURFACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SURFACE", /* tp_name */ + sizeof(ACIS_Entity_SURFACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_SURFACE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_SURFACE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SURFACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_SURFACE, /* tp_methods */ + ACIS_Entity_members_SURFACE, /* tp_members */ + ACIS_Entity_getseters_SURFACE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_SURFACE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * CONE class + * 3D ACIS Modeler - CONE wrapper */ -int -a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_CONE(ACIS_Entity_CONE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_CONE_repr(a3dp_CONE *self) +static PyObject * +ACIS_Entity_repr_CONE(ACIS_Entity_CONE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("CONE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_CONE_str(a3dp_CONE *self) +static PyObject * +ACIS_Entity_str_CONE(ACIS_Entity_CONE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -722,30 +1404,92 @@ a3dp_CONE_str(a3dp_CONE *self) return PyUnicode_FromFormat("CONE object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_CONE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_CONE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_CONE[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_CONE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.CONE", /* tp_name */ + sizeof(ACIS_Entity_CONE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_CONE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_CONE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS CONE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_CONE, /* tp_methods */ + ACIS_Entity_members_CONE, /* tp_members */ + ACIS_Entity_getseters_CONE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_CONE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * PLANE class + * 3D ACIS Modeler - PLANE wrapper */ -int -a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_PLANE(ACIS_Entity_PLANE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_PLANE_repr(a3dp_PLANE *self) +static PyObject * +ACIS_Entity_repr_PLANE(ACIS_Entity_PLANE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("PLANE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_PLANE_str(a3dp_PLANE *self) +static PyObject * +ACIS_Entity_str_PLANE(ACIS_Entity_PLANE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -756,30 +1500,92 @@ a3dp_PLANE_str(a3dp_PLANE *self) return PyUnicode_FromFormat("PLANE object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_PLANE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_PLANE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_PLANE[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_PLANE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.PLANE", /* tp_name */ + sizeof(ACIS_Entity_PLANE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_PLANE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_PLANE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS PLANE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_PLANE, /* tp_methods */ + ACIS_Entity_members_PLANE, /* tp_members */ + ACIS_Entity_getseters_PLANE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_PLANE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * SPHERE class + * 3D ACIS Modeler - SPHERE wrapper */ -int -a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_SPHERE(ACIS_Entity_SPHERE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_SPHERE_repr(a3dp_SPHERE *self) +static PyObject * +ACIS_Entity_repr_SPHERE(ACIS_Entity_SPHERE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SPHERE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_SPHERE_str(a3dp_SPHERE *self) +static PyObject * +ACIS_Entity_str_SPHERE(ACIS_Entity_SPHERE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -790,30 +1596,92 @@ a3dp_SPHERE_str(a3dp_SPHERE *self) return PyUnicode_FromFormat("SPHERE object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_SPHERE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_SPHERE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_SPHERE[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_SPHERE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPHERE", /* tp_name */ + sizeof(ACIS_Entity_SPHERE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_SPHERE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_SPHERE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPHERE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_SPHERE, /* tp_methods */ + ACIS_Entity_members_SPHERE, /* tp_members */ + ACIS_Entity_getseters_SPHERE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_SPHERE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * SPLINE class + * 3D ACIS Modeler - SPLINE wrapper */ -int -a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_SPLINE(ACIS_Entity_SPLINE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_SPLINE_repr(a3dp_SPLINE *self) +static PyObject * +ACIS_Entity_repr_SPLINE(ACIS_Entity_SPLINE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SPLINE object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_SPLINE_str(a3dp_SPLINE *self) +static PyObject * +ACIS_Entity_str_SPLINE(ACIS_Entity_SPLINE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -824,30 +1692,92 @@ a3dp_SPLINE_str(a3dp_SPLINE *self) return PyUnicode_FromFormat("SPLINE object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_SPLINE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_SPLINE[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_SPLINE[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_SPLINE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPLINE", /* tp_name */ + sizeof(ACIS_Entity_SPLINE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_SPLINE, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_SPLINE, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPLINE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_SPLINE, /* tp_methods */ + ACIS_Entity_members_SPLINE, /* tp_members */ + ACIS_Entity_getseters_SPLINE, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_SPLINE, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * TORUS class + * 3D ACIS Modeler - TORUS wrapper */ -int -a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_TORUS(ACIS_Entity_TORUS *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -PyObject * -a3dp_TORUS_repr(a3dp_TORUS *self) +static PyObject * +ACIS_Entity_repr_TORUS(ACIS_Entity_TORUS *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("TORUS object with name '%s' and ID '%i'", _name, _id); } -PyObject * -a3dp_TORUS_str(a3dp_TORUS *self) +static PyObject * +ACIS_Entity_str_TORUS(ACIS_Entity_TORUS *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -858,18 +1788,80 @@ a3dp_TORUS_str(a3dp_TORUS *self) return PyUnicode_FromFormat("TORUS object (%s)", acis_obj_status); } +static PyGetSetDef + ACIS_Entity_getseters_TORUS[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_TORUS[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Entity_methods_TORUS[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Entity_type_TORUS = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.TORUS", /* tp_name */ + sizeof(ACIS_Entity_TORUS), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_Entity_repr_TORUS, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_Entity_str_TORUS, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS TORUS class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_TORUS, /* tp_methods */ + ACIS_Entity_members_TORUS, /* tp_members */ + ACIS_Entity_getseters_TORUS, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_TORUS, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + /** - * surface class + * 3D ACIS Modeler - surface wrapper */ -void -a3dp_surface_dealloc(a3dp_surface *self) +static void +ACIS_Entity_dealloc_surface(ACIS_Entity_surface *self) { Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * -a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +static PyObject * +ACIS_Entity_new_surface(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started if (!is_modeler_started()) @@ -878,9 +1870,9 @@ a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return NULL; } - a3dp_surface *self; + ACIS_Entity_surface *self; - self = (a3dp_surface *) type->tp_alloc(type, 0); + self = (ACIS_Entity_surface *) type->tp_alloc(type, 0); if (self != NULL) { // Just getting rid of the dangling pointer @@ -890,16 +1882,16 @@ a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int -a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs) +static int +ACIS_Entity_init_surface(ACIS_Entity_surface *self, PyObject *args, PyObject *kwargs) { return 0; } -PyObject * -a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg) +static PyObject * +ACIS_Entity_method_surface_eval_normal(ACIS_Entity_surface *self, PyObject *arg) { - if (!_PyCheck_SPApar_pos(arg)) + if (!_ACIS_check_SPApar_pos(arg)) { PyErr_SetString(PyExc_TypeError, "Expecting a SPApar_pos object"); return NULL; @@ -907,22 +1899,22 @@ a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg) Py_INCREF(arg); - SPApar_pos *&_pos = ((a3dp_SPApar_pos *) arg)->_acis_obj; + SPApar_pos *&_pos = ((ACIS_GeometricAtoms_SPApar_pos *) arg)->_acis_obj; SPAunit_vector _retval = self->_acis_obj->eval_normal(*_pos); - PyObject *_retobj = _PyNew_SPAunit_vector(); - *((a3dp_SPAunit_vector *) _retobj)->_acis_obj = _retval; + PyObject *_retobj = _ACIS_new_SPAunit_vector(); + *((ACIS_GeometricAtoms_SPAunit_vector *) _retobj)->_acis_obj = _retval; Py_DECREF(arg); return _retobj; } -PyObject * -a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg) +static PyObject * +ACIS_Entity_method_surface_eval_position(ACIS_Entity_surface *self, PyObject *arg) { - if (!_PyCheck_SPApar_pos(arg)) + if (!_ACIS_check_SPApar_pos(arg)) { PyErr_SetString(PyExc_TypeError, "Expecting a SPApar_pos object"); return NULL; @@ -930,540 +1922,432 @@ a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg) Py_INCREF(arg); - SPApar_pos *&_pos = ((a3dp_SPApar_pos *) arg)->_acis_obj; + SPApar_pos *&_pos = ((ACIS_GeometricAtoms_SPApar_pos *) arg)->_acis_obj; SPAposition _retval = self->_acis_obj->eval_position(*_pos); - PyObject *_retobj = _PyNew_SPAposition(); - *((a3dp_SPAposition *) _retobj)->_acis_obj = _retval; + PyObject *_retobj = _ACIS_new_SPAposition(); + *((ACIS_GeometricAtoms_SPAposition *) _retobj)->_acis_obj = _retval; Py_DECREF(arg); return _retobj; } -PyObject *_PyNew_ENTITY() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_ENTITY, NULL); -} +static PyGetSetDef + ACIS_Entity_getseters_surface[] = + { + { NULL } /* Sentinel */ + }; -bool _PyCheck_ENTITY(PyObject *ob) -{ - int retval = PyObject_IsInstance(ob, (PyObject *) &a3dp_type_ENTITY); - if (retval < 0) +static PyMemberDef + ACIS_Entity_members_surface[] = { - PyErr_SetString(PyExc_TypeError, "Problem with ENTITY type cheking"); - return false; - } - return retval != 0; -} + { NULL } /* Sentinel */ + }; -PyObject *_PyNew_BODY() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_BODY, NULL); -} +static PyMethodDef + ACIS_Entity_methods_surface[] = + { + { "eval_normal", (PyCFunction) ACIS_Entity_method_surface_eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, + { "eval_position", (PyCFunction) ACIS_Entity_method_surface_eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, + { NULL } /* Sentinel */ + }; -bool _PyCheck_BODY(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_BODY; -} +static PyTypeObject + ACIS_Entity_type_surface = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.surface", /* tp_name */ + sizeof(ACIS_Entity_surface), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_Entity_dealloc_surface, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS surface class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Entity_methods_surface, /* tp_methods */ + ACIS_Entity_members_surface, /* tp_members */ + ACIS_Entity_getseters_surface, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Entity_init_surface, /* tp_init */ + 0, /* tp_alloc */ + ACIS_Entity_new_surface, /* tp_new */ + }; + + +/* + * Python Module Definitions + */ -PyObject *_PyNew_FACE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_FACE, NULL); -} +// Module documentation can be accessible via __doc__ +const char *module_name = "Entity"; +const char *module_documentation = "Contains 3D ACIS Modeler entities, such as BODY, FACE, WIRE, etc."; -bool _PyCheck_FACE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_FACE; -} +static PyModuleDef + ACIS_Entity_module = + { + PyModuleDef_HEAD_INIT, + module_name, + module_documentation, + -1, + NULL, NULL, NULL, NULL, NULL + }; + +PyMODINIT_FUNC +PyInit_Entity(void) +{ + // Create a Python module, ACIS.Topology + PyObject *m; + m = PyModule_Create(&ACIS_Entity_module); + if (m == NULL) + return NULL; -PyObject *_PyNew_EDGE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_EDGE, NULL); -} + // Add ENTITY to the module + if (PyType_Ready(&ACIS_Entity_type_ENTITY) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_ENTITY); + PyModule_AddObject(m, "ENTITY", (PyObject *) &ACIS_Entity_type_ENTITY); -bool _PyCheck_EDGE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_EDGE; -} + // Add BODY to the module + ACIS_Entity_type_BODY.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_BODY) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_BODY); + PyModule_AddObject(m, "BODY", (PyObject *) &ACIS_Entity_type_BODY); -PyObject *_PyNew_WIRE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_WIRE, NULL); -} + // Add FACE to the module + ACIS_Entity_type_FACE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_FACE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_FACE); + PyModule_AddObject(m, "FACE", (PyObject *) &ACIS_Entity_type_FACE); -bool _PyCheck_WIRE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_WIRE; -} + // Add EDGE to the module + ACIS_Entity_type_EDGE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_EDGE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_EDGE); + PyModule_AddObject(m, "EDGE", (PyObject *) &ACIS_Entity_type_EDGE); -PyObject *_PyNew_LUMP() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_LUMP, NULL); -} + // Add WIRE to the module + ACIS_Entity_type_WIRE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_WIRE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_WIRE); + PyModule_AddObject(m, "WIRE", (PyObject *) &ACIS_Entity_type_WIRE); -bool _PyCheck_LUMP(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_LUMP; -} + // Add LUMP to the module + ACIS_Entity_type_LUMP.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_LUMP) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_LUMP); + PyModule_AddObject(m, "LUMP", (PyObject *) &ACIS_Entity_type_LUMP); -PyObject *_PyNew_SHELL() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SHELL, NULL); -} + // Add SHELL to the module + ACIS_Entity_type_SHELL.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_SHELL) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_SHELL); + PyModule_AddObject(m, "SHELL", (PyObject *) &ACIS_Entity_type_SHELL); -bool _PyCheck_SHELL(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SHELL; -} + // Add SUBSHELL to the module + ACIS_Entity_type_SUBSHELL.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_SUBSHELL) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_SUBSHELL); + PyModule_AddObject(m, "SUBSHELL", (PyObject *) &ACIS_Entity_type_SUBSHELL); -PyObject *_PyNew_SUBSHELL() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SUBSHELL, NULL); -} + // Add COEDGE to the module + ACIS_Entity_type_COEDGE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_COEDGE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_COEDGE); + PyModule_AddObject(m, "COEDGE", (PyObject *) &ACIS_Entity_type_COEDGE); -bool _PyCheck_SUBSHELL(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SUBSHELL; -} + // Add LOOP to the module + ACIS_Entity_type_LOOP.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_LOOP) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_LOOP); + PyModule_AddObject(m, "LOOP", (PyObject *) &ACIS_Entity_type_LOOP); -PyObject *_PyNew_COEDGE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_COEDGE, NULL); -} + // Add VERTEX to the module + ACIS_Entity_type_VERTEX.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_VERTEX) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_VERTEX); + PyModule_AddObject(m, "VERTEX", (PyObject *) &ACIS_Entity_type_VERTEX); -bool _PyCheck_COEDGE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_COEDGE; -} + // Add SURFACE to the module + ACIS_Entity_type_SURFACE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_SURFACE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_SURFACE); + PyModule_AddObject(m, "SURFACE", (PyObject *) &ACIS_Entity_type_SURFACE); -PyObject *_PyNew_LOOP() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_LOOP, NULL); -} + // Add CONE to the module + ACIS_Entity_type_CONE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_CONE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_CONE); + PyModule_AddObject(m, "CONE", (PyObject *) &ACIS_Entity_type_CONE); -bool _PyCheck_LOOP(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_LOOP; -} + // Add PLANE to the module + ACIS_Entity_type_PLANE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_PLANE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_PLANE); + PyModule_AddObject(m, "PLANE", (PyObject *) &ACIS_Entity_type_PLANE); -PyObject *_PyNew_VERTEX() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_VERTEX, NULL); -} + // Add SPHERE to the module + ACIS_Entity_type_SPHERE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_SPHERE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_SPHERE); + PyModule_AddObject(m, "SPHERE", (PyObject *) &ACIS_Entity_type_SPHERE); -bool _PyCheck_VERTEX(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_VERTEX; + // Add SPLINE to the module + ACIS_Entity_type_SPLINE.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_SPLINE) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_SPLINE); + PyModule_AddObject(m, "SPLINE", (PyObject *) &ACIS_Entity_type_SPLINE); + + // Add TORUS to the module + ACIS_Entity_type_TORUS.tp_base = &ACIS_Entity_type_ENTITY; + if (PyType_Ready(&ACIS_Entity_type_TORUS) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_TORUS); + PyModule_AddObject(m, "TORUS", (PyObject *) &ACIS_Entity_type_TORUS); + + // Add surface to the module + if (PyType_Ready(&ACIS_Entity_type_surface) < 0) + return NULL; + Py_INCREF(&ACIS_Entity_type_surface); + PyModule_AddObject(m, "surface", (PyObject *) &ACIS_Entity_type_surface); + + // Return the module and all included objects + return m; } -PyObject *_PyNew_SURFACE() +PyObject *_ACIS_new_ENTITY() { - return PyObject_CallObject((PyObject *) &a3dp_type_SURFACE, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_ENTITY, NULL); } -bool _PyCheck_SURFACE(PyObject *ob) +bool _ACIS_check_ENTITY(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SURFACE; + int retval = PyObject_IsInstance(ob, (PyObject *) &ACIS_Entity_type_ENTITY); + if (retval < 0) + { + PyErr_SetString(PyExc_TypeError, "Problem with ENTITY type cheking"); + return false; + } + return retval != 0; } -PyObject *_PyNew_CONE() +PyObject *_ACIS_new_BODY() { - return PyObject_CallObject((PyObject *) &a3dp_type_CONE, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_BODY, NULL); } -bool _PyCheck_CONE(PyObject *ob) +bool _ACIS_check_BODY(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_CONE; + return Py_TYPE(ob) == &ACIS_Entity_type_BODY; } -PyObject *_PyNew_PLANE() +PyObject *_ACIS_new_FACE() { - return PyObject_CallObject((PyObject *) &a3dp_type_PLANE, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_FACE, NULL); } -bool _PyCheck_PLANE(PyObject *ob) +bool _ACIS_check_FACE(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_PLANE; + return Py_TYPE(ob) == &ACIS_Entity_type_FACE; } -PyObject *_PyNew_SPHERE() +PyObject *_ACIS_new_EDGE() { - return PyObject_CallObject((PyObject *) &a3dp_type_SPHERE, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_EDGE, NULL); } -bool _PyCheck_SPHERE(PyObject *ob) +bool _ACIS_check_EDGE(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPHERE; + return Py_TYPE(ob) == &ACIS_Entity_type_EDGE; } -PyObject *_PyNew_SPLINE() +PyObject *_ACIS_new_WIRE() { - return PyObject_CallObject((PyObject *) &a3dp_type_SPLINE, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_WIRE, NULL); } -bool _PyCheck_SPLINE(PyObject *ob) +bool _ACIS_check_WIRE(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPLINE; + return Py_TYPE(ob) == &ACIS_Entity_type_WIRE; } -PyObject *_PyNew_TORUS() +PyObject *_ACIS_new_LUMP() { - return PyObject_CallObject((PyObject *) &a3dp_type_TORUS, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_LUMP, NULL); } -bool _PyCheck_TORUS(PyObject *ob) +bool _ACIS_check_LUMP(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_TORUS; + return Py_TYPE(ob) == &ACIS_Entity_type_LUMP; } -PyObject *_PyNew_surface() +PyObject *_ACIS_new_SHELL() { - return PyObject_CallObject((PyObject *) &a3dp_type_surface, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SHELL, NULL); } -bool _PyCheck_surface(PyObject *ob) +bool _ACIS_check_SHELL(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_surface; + return Py_TYPE(ob) == &ACIS_Entity_type_SHELL; } -void _a3dp_make_null(PyObject *ob) +PyObject *_ACIS_new_SUBSHELL() { - if (_PyCheck_ENTITY(ob)) - { - ((a3dp_ENTITY *) ob)->_acis_obj = NULL; - } + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SUBSHELL, NULL); } -void _a3dp_set_entity(PyObject *ob, ENTITY *ent) +bool _ACIS_check_SUBSHELL(PyObject *ob) { - ((a3dp_ENTITY *)ob)->_acis_obj = ent; + return Py_TYPE(ob) == &ACIS_Entity_type_SUBSHELL; } -/** - * ENTITY_LIST class - */ - -void -a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self) +PyObject *_ACIS_new_COEDGE() { - // First, clear the contents of the ENTITY_LIST instance - self->_acis_obj->clear(); - - // Use ACIS_DELETE macro for ENTITY_LIST - ACIS_DELETE self->_acis_obj; - - // Delete the python object itself - Py_TYPE(self)->tp_free((PyObject *) self); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_COEDGE, NULL); } -PyObject * -a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +bool _ACIS_check_COEDGE(PyObject *ob) { - a3dp_ENTITY_LIST *self; - - self = (a3dp_ENTITY_LIST *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; + return Py_TYPE(ob) == &ACIS_Entity_type_COEDGE; } -int -a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self) +PyObject *_ACIS_new_LOOP() { - // ENTITY_LIST takes no arguments, so parsing is necessary - self->_acis_obj = ACIS_NEW ENTITY_LIST(); - return 0; + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_LOOP, NULL); } -PyObject * -a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self) +bool _ACIS_check_LOOP(PyObject *ob) { - self->_acis_obj->init(); - Py_RETURN_NONE; + return Py_TYPE(ob) == &ACIS_Entity_type_LOOP; } -PyObject * -a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self) +PyObject *_ACIS_new_VERTEX() { - self->_acis_obj->clear(); - Py_RETURN_NONE; + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_VERTEX, NULL); } -PyObject * -a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg) +bool _ACIS_check_VERTEX(PyObject *ob) { - // Treat arg as a borrowed reference - Py_INCREF(arg); - - int index = -1; - - if (!_PyCheck_ENTITY(arg)) - { - if (!_PyCheck_ENTITY_LIST(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY or ENTITY_LIST object"); - return NULL; - } - else - { - // This function returns void - self->_acis_obj->add(*((a3dp_ENTITY_LIST *) arg)->_acis_obj); - } - } - else - { - // This function returns the added ENTITY's index number - index = self->_acis_obj->add(((a3dp_ENTITY *) arg)->_acis_obj); - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - if (index != -1) - { - return PyLong_FromLong(index); - } - else - { - Py_RETURN_NONE; - } + return Py_TYPE(ob) == &ACIS_Entity_type_VERTEX; } -PyObject * -a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg) +PyObject *_ACIS_new_SURFACE() { - // Treat arg as a borrowed reference - Py_INCREF(arg); - - int index = -1; - - if (!_PyCheck_ENTITY(arg)) - { - if (!_PyCheck_ENTITY_LIST(arg)) - { - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY, an ENTITY_LIST or an integer object"); - return NULL; - } - else - { - // This function returns the index number - index = self->_acis_obj->remove((int) PyLong_AsLong(arg)); - } - } - else - { - // This function returns void - self->_acis_obj->remove(*((a3dp_ENTITY_LIST *) arg)->_acis_obj); - } - } - else - { - // This function returns the removed ENTITY's index number - index = self->_acis_obj->remove(((a3dp_ENTITY *) arg)->_acis_obj); - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - if (index != -1) - { - return PyLong_FromLong(index); - } - else - { - Py_RETURN_NONE; - } + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SURFACE, NULL); } -PyObject * -a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self) +bool _ACIS_check_SURFACE(PyObject *ob) { - return PyLong_FromLong(self->_acis_obj->count()); + return Py_TYPE(ob) == &ACIS_Entity_type_SURFACE; } -PyObject * -a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self) +PyObject *_ACIS_new_CONE() { - return PyLong_FromLong(self->_acis_obj->iteration_count()); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_CONE, NULL); } -PyObject * -a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self) +bool _ACIS_check_CONE(PyObject *ob) { - self->_acis_obj->reverse(); - Py_RETURN_NONE; + return Py_TYPE(ob) == &ACIS_Entity_type_CONE; } -PyObject * -a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg) +PyObject *_ACIS_new_PLANE() { - // Treat arg as a borrowed reference - Py_INCREF(arg); - - if (!_PyCheck_ENTITY(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY object"); - return NULL; - } - - int index = self->_acis_obj->lookup(((a3dp_ENTITY *) arg)->_acis_obj); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - return PyLong_FromLong(index); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_PLANE, NULL); } -PyObject * -a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self) +bool _ACIS_check_PLANE(PyObject *ob) { - return PyLong_FromLong(self->_acis_obj->byte_count()); + return Py_TYPE(ob) == &ACIS_Entity_type_PLANE; } -PyObject * -a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self) +PyObject *_ACIS_new_SPHERE() { - ENTITY *_elem = self->_acis_obj->first(); - PyObject *retobj = __convert_entity(_elem); - return retobj; + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SPHERE, NULL); } -PyObject * -a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self) +bool _ACIS_check_SPHERE(PyObject *ob) { - PyObject *retobj; - ENTITY *_elem = self->_acis_obj->next(); - - if (_elem) - { - retobj = __convert_entity(_elem); - } - else - { - // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - - return retobj; + return Py_TYPE(ob) == &ACIS_Entity_type_SPHERE; } -PyObject * -a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg) +PyObject *_ACIS_new_SPLINE() { - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an integer object"); - return NULL; - } - - Py_INCREF(arg); - int _from_index = (int) PyLong_AsLong(arg); - Py_DECREF(arg); - - PyObject *retobj; - ENTITY *_elem = self->_acis_obj->next_from(_from_index); - - if (_elem) - { - retobj = __convert_entity(_elem); - } - else - { - // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - - return retobj; + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SPLINE, NULL); } -PyObject * -a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self) +bool _ACIS_check_SPLINE(PyObject *ob) { - /* This function will create a Python generator/iterator */ - - // Reference increment is necessary, otherwise this ENTITY_LIST will be garbage collected - Py_INCREF(self); - - // Iterator/Generator creation functions always return self! - return (PyObject *) self; + return Py_TYPE(ob) == &ACIS_Entity_type_SPLINE; } -PyObject * -a3dp_ENTITYLIST_iter(PyObject *self) +PyObject *_ACIS_new_TORUS() { - /* Must have the same signature as PyObject_GetIter() */ - - // Move the ENTITY_LIST pointer to the beginning - a3dp_ENTITYLIST__init((a3dp_ENTITY_LIST *) self); - - Py_INCREF(self); - return self; + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_TORUS, NULL); } -PyObject * -a3dp_ENTITYLIST_iter_next(PyObject *self) +bool _ACIS_check_TORUS(PyObject *ob) { - /* Must have the same signature as PyIter_Next() */ - - // Convert the input argument to a ENTITY_LIST object - a3dp_ENTITY_LIST *_ent_list = (a3dp_ENTITY_LIST *) self; - - // Return the next element - return a3dp_ENTITYLIST__next(_ent_list); + return Py_TYPE(ob) == &ACIS_Entity_type_TORUS; } - -PyObject * -_PyNew_ENTITY_LIST() +PyObject *_ACIS_new_surface() { - return PyObject_CallObject((PyObject *) &a3dp_type_ENTITYLIST, NULL); + return PyObject_CallObject((PyObject *) &ACIS_Entity_type_surface, NULL); } -bool -_PyCheck_ENTITY_LIST(PyObject *ob) +bool _ACIS_check_surface(PyObject *ob) { - if (Py_TYPE(ob) == &a3dp_type_ENTITYLIST) - return true; - else - return false; + return Py_TYPE(ob) == &ACIS_Entity_type_surface; } -PyObject * -__convert_entity(ENTITY *ent) +void _ACIS_make_null(PyObject *ob) { - // Find the type name of the entity - const char *_type_name = ent->type_name(); - - // We could use a hashing function here... - PyObject *_retobj; - if (strcmp("body", _type_name) == 0) - { - _retobj = _PyNew_BODY(); - _a3dp_set_entity(_retobj, ent); - } - else if (strcmp("face", _type_name) == 0) - { - _retobj = _PyNew_FACE(); - _a3dp_set_entity(_retobj, ent); - } - else if (strcmp("surface", _type_name) == 0) + if (_ACIS_check_ENTITY(ob)) { - _retobj = _PyNew_SURFACE(); - _a3dp_set_entity(_retobj, ent); + ((ACIS_Entity_ENTITY *) ob)->_acis_obj = NULL; } +} - return _retobj; +void _ACIS_set_entity(PyObject *ob, ENTITY *ent) +{ + ((ACIS_Entity_ENTITY *)ob)->_acis_obj = ent; } diff --git a/src/acis_entity.h b/src/acis_entity.h index 7743a66..6e33c32 100644 --- a/src/acis_entity.h +++ b/src/acis_entity.h @@ -9,14 +9,24 @@ * */ -#ifndef A3DPY_ENTITY_H -#define A3DPY_ENTITY_H +#ifndef ACIS_ENTITY_H +#define ACIS_ENTITY_H #include #include -#include "acis_includes.h" -#include "acis_operators.h" +#include "kernapi.hxx" +#include +#include +#include +#include +#include +#include +#include + +#include "acis_geometric_atoms.h" + +#include "acis_entity_export.h" #ifdef __cplusplus @@ -32,55 +42,72 @@ typedef struct ENTITY *_acis_obj; PyObject *attrib_name; PyObject *attrib_object_id; -} a3dp_ENTITY; - -int a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg); -int a3dp_ENTITY_clear(a3dp_ENTITY *self); -void a3dp_ENTITY_dealloc(a3dp_ENTITY *self); -PyObject *a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_ENTITY_repr(a3dp_ENTITY *self); -PyObject *a3dp_ENTITY_str(a3dp_ENTITY *self); -PyObject *a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); -int a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); -PyObject *a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); -int a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); -PyObject *a3dp_ENTITY_type_name(PyObject *self); +} ACIS_Entity_ENTITY; + +int ACIS_ENTITY_EXPORT ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg); + +int ACIS_ENTITY_EXPORT ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self); + +void ACIS_ENTITY_EXPORT ACIS_Entity_dealloc_ENTITY(ACIS_Entity_ENTITY *self); + +PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs); + +int ACIS_ENTITY_EXPORT ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwargs); + +PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self); + +PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self); + +PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); + +int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); + +PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); + +int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); + +PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_type_name(PyObject *self); static PyGetSetDef - a3dp_getseters_ENTITY[] = + ACIS_Entity_getseters_ENTITY[] = + { + { (char *) "name", (getter) ACIS_Entity_method_ENTITY_get_attrib_name, (setter) ACIS_Entity_method_ENTITY_set_attrib_name, (char *) "object name", NULL }, + { (char *) "id", (getter) ACIS_Entity_method_ENTITY_get_attrib_obj_id, (setter) ACIS_Entity_method_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Entity_members_ENTITY[] = { - { (char *) "name", (getter) a3dp_ENTITY_get_attrib_name, (setter) a3dp_ENTITY_set_attrib_name, (char *) "object name", NULL }, - { (char *) "id", (getter) a3dp_ENTITY_get_attrib_obj_id, (setter) a3dp_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, { NULL } /* Sentinel */ }; static PyMethodDef - a3dp_methods_ENTITY[] = + ACIS_Entity_methods_ENTITY[] = { - { "type_name", (PyCFunction) a3dp_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, + { "type_name", (PyCFunction) ACIS_Entity_method_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, { NULL } /* Sentinel */ }; static PyTypeObject - a3dp_type_ENTITY = + ACIS_Entity_type_ENTITY = { PyVarObject_HEAD_INIT(NULL, 0) "ACIS.ENTITY", /* tp_name */ - sizeof(a3dp_ENTITY), /* tp_basicsize */ + sizeof(ACIS_Entity_ENTITY), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor) a3dp_ENTITY_dealloc, /* tp_dealloc */ + (destructor) ACIS_Entity_dealloc_ENTITY, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ - (reprfunc) a3dp_ENTITY_repr, /* tp_repr */ + (reprfunc) ACIS_Entity_repr_ENTITY, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - (reprfunc) a3dp_ENTITY_str, /* tp_str */ + (reprfunc) ACIS_Entity_str_ENTITY, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -88,1124 +115,198 @@ static PyTypeObject Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ "ACIS ENTITY class", /* tp_doc */ - (traverseproc) a3dp_ENTITY_traverse, /* tp_traverse */ - (inquiry) a3dp_ENTITY_clear, /* tp_clear */ + (traverseproc) ACIS_Entity_traverse_ENTITY, /* tp_traverse */ + (inquiry) ACIS_Entity_clear_ENTITY, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - a3dp_methods_ENTITY, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_ENTITY, /* tp_getset */ + ACIS_Entity_methods_ENTITY, /* tp_methods */ + ACIS_Entity_members_ENTITY, /* tp_members */ + ACIS_Entity_getseters_ENTITY, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc) a3dp_ENTITY_init, /* tp_init */ + (initproc) ACIS_Entity_init_ENTITY, /* tp_init */ 0, /* tp_alloc */ - a3dp_ENTITY_new, /* tp_new */ + ACIS_Entity_new_ENTITY, /* tp_new */ }; -PyObject *_PyNew_ENTITY(); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_ENTITY(); -bool _PyCheck_ENTITY(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_ENTITY(PyObject *ob); // Define BODY typedef struct { - a3dp_ENTITY base_obj; -} a3dp_BODY; - -int a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_BODY_repr(a3dp_BODY *self); -PyObject *a3dp_BODY_str(a3dp_BODY *self); - -static PyTypeObject - a3dp_type_BODY = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.BODY", /* tp_name */ - sizeof(a3dp_BODY), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_BODY_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_BODY_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS BODY class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_BODY_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_BODY; +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_BODY(); -PyObject *_PyNew_BODY(); - -bool _PyCheck_BODY(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_BODY(PyObject *ob); // Define FACE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_FACE; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_FACE; -int a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FACE_repr(a3dp_FACE *self); -PyObject *a3dp_FACE_str(a3dp_FACE *self); -PyObject *a3dp_FACE__sense(a3dp_FACE *self); -PyObject *a3dp_FACE__geometry(a3dp_FACE *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_FACE(); -static PyMethodDef - a3dp_methods_FACE[] = - { - { "sense", (PyCFunction) a3dp_FACE__sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, - { "geometry", (PyCFunction) a3dp_FACE__geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_FACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FACE", /* tp_name */ - sizeof(a3dp_FACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_FACE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_FACE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS FACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_FACE, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_FACE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_FACE(); - -bool _PyCheck_FACE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_FACE(PyObject *ob); // Define EDGE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_EDGE; - -int a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_EDGE_repr(a3dp_EDGE *self); -PyObject *a3dp_EDGE_str(a3dp_EDGE *self); - -static PyTypeObject - a3dp_type_EDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.EDGE", /* tp_name */ - sizeof(a3dp_EDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_EDGE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_EDGE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS EDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_EDGE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_EDGE; -PyObject *_PyNew_EDGE(); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_EDGE(); -bool _PyCheck_EDGE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_EDGE(PyObject *ob); // Define WIRE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_WIRE; - -int a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_WIRE_repr(a3dp_WIRE *self); -PyObject *a3dp_WIRE_str(a3dp_WIRE *self); - -static PyTypeObject - a3dp_type_WIRE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.WIRE", /* tp_name */ - sizeof(a3dp_WIRE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_WIRE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_WIRE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS WIRE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_WIRE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_WIRE; -PyObject *_PyNew_WIRE(); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_WIRE(); -bool _PyCheck_WIRE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_WIRE(PyObject *ob); // Define LUMP typedef struct { - a3dp_ENTITY base_obj; -} a3dp_LUMP; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_LUMP; -int a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_LUMP_repr(a3dp_LUMP *self); -PyObject *a3dp_LUMP_str(a3dp_LUMP *self); - -static PyTypeObject - a3dp_type_LUMP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LUMP", /* tp_name */ - sizeof(a3dp_LUMP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_LUMP_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_LUMP_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LUMP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_LUMP_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LUMP(); - -PyObject *_PyNew_LUMP(); - -bool _PyCheck_LUMP(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_LUMP(PyObject *ob); // Define SHELL typedef struct { - a3dp_ENTITY base_obj; -} a3dp_SHELL; - -int a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SHELL_repr(a3dp_SHELL *self); -PyObject *a3dp_SHELL_str(a3dp_SHELL *self); - -static PyTypeObject - a3dp_type_SHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SHELL", /* tp_name */ - sizeof(a3dp_SHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SHELL_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SHELL_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SHELL_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_SHELL; -PyObject *_PyNew_SHELL(); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SHELL(); -bool _PyCheck_SHELL(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_SHELL(PyObject *ob); // Define SUBSHELL typedef struct { - a3dp_ENTITY base_obj; -} a3dp_SUBSHELL; - -int a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self); -PyObject *a3dp_SUBSHELL_str(a3dp_SUBSHELL *self); - -static PyTypeObject - a3dp_type_SUBSHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SUBSHELL", /* tp_name */ - sizeof(a3dp_SUBSHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SUBSHELL_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SUBSHELL_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SUBSHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SUBSHELL_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_SUBSHELL; -PyObject *_PyNew_SUBSHELL(); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SUBSHELL(); -bool _PyCheck_SUBSHELL(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_SUBSHELL(PyObject *ob); // Define COEDGE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_COEDGE; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_COEDGE; -int a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_COEDGE_repr(a3dp_COEDGE *self); -PyObject *a3dp_COEDGE_str(a3dp_COEDGE *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_COEDGE(); -static PyTypeObject - a3dp_type_COEDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.COEDGE", /* tp_name */ - sizeof(a3dp_COEDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_COEDGE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_COEDGE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS COEDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_COEDGE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_COEDGE(); - -bool _PyCheck_COEDGE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_COEDGE(PyObject *ob); // Define LOOP typedef struct { - a3dp_ENTITY base_obj; -} a3dp_LOOP; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_LOOP; -int a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_LOOP_repr(a3dp_LOOP *self); -PyObject *a3dp_LOOP_str(a3dp_LOOP *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LOOP(); -static PyTypeObject - a3dp_type_LOOP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LOOP", /* tp_name */ - sizeof(a3dp_LOOP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_LOOP_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_LOOP_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LOOP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_LOOP_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_LOOP(); - -bool _PyCheck_LOOP(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_LOOP(PyObject *ob); // Define VERTEX typedef struct { - a3dp_ENTITY base_obj; -} a3dp_VERTEX; - -int a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_VERTEX_repr(a3dp_VERTEX *self); -PyObject *a3dp_VERTEX_str(a3dp_VERTEX *self); - -static PyTypeObject - a3dp_type_VERTEX = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.VERTEX", /* tp_name */ - sizeof(a3dp_VERTEX), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_VERTEX_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_VERTEX_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS VERTEX class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_VERTEX_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_VERTEX; -PyObject *_PyNew_VERTEX(); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_VERTEX(); -bool _PyCheck_VERTEX(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_VERTEX(PyObject *ob); // Define SURFACE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_SURFACE; - -int a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SURFACE_repr(a3dp_SURFACE *self); -PyObject *a3dp_SURFACE_str(a3dp_SURFACE *self); -PyObject *a3dp_SURFACE__equation(a3dp_SURFACE *self); -PyObject *a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_SURFACE; -static PyMethodDef - a3dp_methods_SURFACE[] = - { - { "equation", (PyCFunction) a3dp_SURFACE__equation, METH_NOARGS, "Returns the equation of this SURFACE" }, - { "trans_surface", (PyCFunction) a3dp_SURFACE__trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, - { NULL } /* Sentinel */ - }; +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SURFACE(); -static PyTypeObject - a3dp_type_SURFACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SURFACE", /* tp_name */ - sizeof(a3dp_SURFACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SURFACE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SURFACE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SURFACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SURFACE, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SURFACE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_SURFACE(); - -bool _PyCheck_SURFACE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_SURFACE(PyObject *ob); // Define CONE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_CONE; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_CONE; -int a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_CONE_repr(a3dp_CONE *self); -PyObject *a3dp_CONE_str(a3dp_CONE *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_CONE(); -static PyTypeObject - a3dp_type_CONE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.CONE", /* tp_name */ - sizeof(a3dp_CONE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_CONE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_CONE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS CONE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_CONE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_CONE(); - -bool _PyCheck_CONE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_CONE(PyObject *ob); // Define PLANE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_PLANE; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_PLANE; -int a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_PLANE_repr(a3dp_PLANE *self); -PyObject *a3dp_PLANE_str(a3dp_PLANE *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_PLANE(); -static PyTypeObject - a3dp_type_PLANE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.PLANE", /* tp_name */ - sizeof(a3dp_PLANE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_PLANE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_PLANE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS PLANE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_PLANE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_PLANE(); - -bool _PyCheck_PLANE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_PLANE(PyObject *ob); // Define SPHERE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_SPHERE; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_SPHERE; -int a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPHERE_repr(a3dp_SPHERE *self); -PyObject *a3dp_SPHERE_str(a3dp_SPHERE *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPHERE(); -static PyTypeObject - a3dp_type_SPHERE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPHERE", /* tp_name */ - sizeof(a3dp_SPHERE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPHERE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPHERE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPHERE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPHERE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_SPHERE(); - -bool _PyCheck_SPHERE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_SPHERE(PyObject *ob); // Define SPLINE typedef struct { - a3dp_ENTITY base_obj; -} a3dp_SPLINE; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_SPLINE; -int a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPLINE_repr(a3dp_SPLINE *self); -PyObject *a3dp_SPLINE_str(a3dp_SPLINE *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPLINE(); -static PyTypeObject - a3dp_type_SPLINE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPLINE", /* tp_name */ - sizeof(a3dp_SPLINE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPLINE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPLINE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPLINE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPLINE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - -PyObject *_PyNew_SPLINE(); - -bool _PyCheck_SPLINE(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_SPLINE(PyObject *ob); // Define TORUS typedef struct { - a3dp_ENTITY base_obj; -} a3dp_TORUS; + ACIS_Entity_ENTITY base_obj; +} ACIS_Entity_TORUS; -int a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_TORUS_repr(a3dp_TORUS *self); -PyObject *a3dp_TORUS_str(a3dp_TORUS *self); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_TORUS(); -static PyTypeObject - a3dp_type_TORUS = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.TORUS", /* tp_name */ - sizeof(a3dp_TORUS), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_TORUS_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_TORUS_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS TORUS class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_TORUS_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_TORUS(); - -bool _PyCheck_TORUS(PyObject *ob); +bool ACIS_ENTITY_EXPORT _ACIS_check_TORUS(PyObject *ob); // Define surface typedef struct { surface* _acis_obj; -} a3dp_surface; +} ACIS_Entity_surface; -void a3dp_surface_dealloc(a3dp_surface *self); -PyObject *a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg); -PyObject *a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg); +PyObject ACIS_ENTITY_EXPORT *_ACIS_new_surface(); -static PyMethodDef - a3dp_methods_surface[] = - { - { "eval_normal", (PyCFunction) a3dp_surface__eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, - { "eval_position", (PyCFunction) a3dp_surface__eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_surface = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.surface", /* tp_name */ - sizeof(a3dp_surface), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_surface_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS surface class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_surface, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_surface_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_surface_new, /* tp_new */ - }; - -PyObject *_PyNew_surface(); - -bool _PyCheck_surface(PyObject *ob); - -// Define ENTITY_LIST -typedef struct -{ - PyObject_HEAD - ENTITY_LIST *_acis_obj; -} a3dp_ENTITY_LIST; - -void a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST_iter(PyObject *self); -PyObject *a3dp_ENTITYLIST_iter_next(PyObject *self); - -static PyMethodDef - a3dp_methods_ENTITY_LIST[] = - { - { "add", (PyCFunction) a3dp_ENTITYLIST__add, METH_O, "Adds an entity or entities to the list" }, - { "remove", (PyCFunction) a3dp_ENTITYLIST__remove, METH_O, "Removes an entity or entities from the list" }, - { "count", (PyCFunction) a3dp_ENTITYLIST__count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, - { "iteration_count", (PyCFunction) a3dp_ENTITYLIST__iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, - { "init", (PyCFunction) a3dp_ENTITYLIST__init, METH_NOARGS, "Adds an entity or entities to the list" }, - { "clear", (PyCFunction) a3dp_ENTITYLIST__clear, METH_NOARGS, "Clear all entries from the list and reset indexes and counters for reuse" }, - { "lookup", (PyCFunction) a3dp_ENTITYLIST__lookup, METH_O, "Adds an entity or entities to the list" }, - { "reverse", (PyCFunction) a3dp_ENTITYLIST__reverse, METH_NOARGS, "Adds an entity or entities to the list" }, - { "byte_count", (PyCFunction) a3dp_ENTITYLIST__byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, - { "first", (PyCFunction) a3dp_ENTITYLIST__first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, - { "next", (PyCFunction) a3dp_ENTITYLIST__next, METH_NOARGS, "Returns the next undeleted (live) entry" }, - { "next_from", (PyCFunction) a3dp_ENTITYLIST__next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, - { "array", (PyCFunction) a3dp_ENTITYLIST__array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_ENTITYLIST = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.ENTITY_LIST", /* tp_name */ - sizeof(a3dp_ENTITY_LIST), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_ENTITYLIST_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS ENTITY_LIST class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) a3dp_ENTITYLIST_iter, /* tp_iter */ - (iternextfunc) a3dp_ENTITYLIST_iter_next, /* tp_iternext */ - a3dp_methods_ENTITY_LIST, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_ENTITYLIST_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_ENTITYLIST_new, /* tp_new */ - }; - -PyObject *_PyNew_ENTITY_LIST(); - -bool _PyCheck_ENTITY_LIST(PyObject *ob); - -PyObject *__convert_entity(ENTITY *ent); +bool ACIS_ENTITY_EXPORT _ACIS_check_surface(PyObject *ob); // Additional functions @@ -1214,12 +315,12 @@ PyObject *__convert_entity(ENTITY *ent); * Sets the internal ocis_obj variable to NULL * @param ob Topology object, such as ENTITY, BODY, FACE, etc. */ -void _a3dp_make_null(PyObject *ob); +void ACIS_ENTITY_EXPORT _ACIS_make_null(PyObject *ob); -void _a3dp_set_entity(PyObject *ob, ENTITY *ent); +void ACIS_ENTITY_EXPORT _ACIS_set_entity(PyObject *ob, ENTITY *ent); #ifdef __cplusplus } #endif -#endif // !A3DPY_ENTITY_H +#endif // !ACIS_ENTITY_H diff --git a/src/acis_enums.cpp b/src/acis_enums.cpp deleted file mode 100644 index bdb4100..0000000 --- a/src/acis_enums.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "acis_enums.h" - - -PyObject *_PyNew_NDBOOL_KEEP() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_NDBOOLKEEP, NULL); -} - -bool _PyCheck_NDBOOL_KEEP(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_NDBOOLKEEP; -} - -PyObject *_PyNew_sweep_bool_type() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_sweepbooltype, NULL); -} - -bool _PyCheck_sweep_bool_type(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_sweepbooltype; -} diff --git a/src/acis_enums.h b/src/acis_enums.h deleted file mode 100644 index 695ac49..0000000 --- a/src/acis_enums.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef A3DPY_ENUMS_H -#define A3DPY_ENUMS_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// Define NDBOOL_KEEP enum -typedef struct { - PyObject_HEAD -} a3dp_NDBOOL_KEEP; - -/** - * NDBOOL_KEEP enum - */ - -static PyTypeObject - a3dp_type_NDBOOLKEEP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.NDBOOL_KEEP", /* tp_name */ - sizeof(a3dp_NDBOOL_KEEP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ - }; - -PyObject *_PyNew_NDBOOL_KEEP(); -bool _PyCheck_NDBOOL_KEEP(PyObject *ob); - -// Define sweep_bool_type enum -typedef struct { - PyObject_HEAD -} a3dp_sweep_bool_type; - -/** - * sweep_bool_type enum - */ - -static PyTypeObject - a3dp_type_sweepbooltype = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_bool_type", /* tp_name */ - sizeof(a3dp_sweep_bool_type), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Sweep to body boolean operation type", /* tp_doc */ - }; - -PyObject *_PyNew_sweep_bool_type(); -bool _PyCheck_sweep_bool_type(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !A3DPY_ENUMS_H diff --git a/src/acis_geometric_atoms.cpp b/src/acis_geometric_atoms.cpp new file mode 100644 index 0000000..042a9ce --- /dev/null +++ b/src/acis_geometric_atoms.cpp @@ -0,0 +1,2778 @@ +#include "acis_geometric_atoms.h" + + +/** + * SPAposition wrapper + */ + +static void +ACIS_GeometricAtoms_dealloc_SPAposition(ACIS_GeometricAtoms_SPAposition *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_GeometricAtoms_new_SPAposition(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_GeometricAtoms_SPAposition *self; + + self = (ACIS_GeometricAtoms_SPAposition *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_GeometricAtoms_init_SPAposition(ACIS_GeometricAtoms_SPAposition *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + static char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAposition(input_x, input_y, input_z); + + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_repr_SPAposition(ACIS_GeometricAtoms_SPAposition *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAposition object (%s, %s, %s)", _x, _y, _z); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_coordinate(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->coordinate(_i)); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_set_coordinate(ACIS_GeometricAtoms_SPAposition *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + static char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The coordinate input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_coordinate(_i, _new_c); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_set_x(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_set_y(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_set_z(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_x(ACIS_GeometricAtoms_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_y(ACIS_GeometricAtoms_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_z(ACIS_GeometricAtoms_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_x_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAposition_x(self); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_y_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAposition_y(self); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAposition_z_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAposition_z(self); +} + +static int +ACIS_GeometricAtoms_method_SPAposition_x_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAposition_set_x(self, value); + return 0; +} + +static int +ACIS_GeometricAtoms_method_SPAposition_y_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAposition_set_y(self, value); + return 0; +} + +static int +ACIS_GeometricAtoms_method_SPAposition_z_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAposition_set_z(self, value); + return 0; +} + +static PyGetSetDef + ACIS_GeometricAtoms_getseters_SPAposition[] = + { + { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAposition_x_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, + { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAposition_y_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, + { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAposition_z_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_GeometricAtoms_members_SPAposition[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_GeometricAtoms_methods_SPAposition[] = + { + { "coordinate", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_coordinate, METH_O, "Returns the i-th component value" }, + { "set_coordinate", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, + { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the x-coordinate value" }, + { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the y-coordinate value" }, + { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the z-coordinate value" }, + { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_x, METH_NOARGS, "Returns the x-coordinate value" }, + { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_y, METH_NOARGS, "Returns the y-coordinate value" }, + { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_z, METH_NOARGS, "Returns the z-coordinate value" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_GeometricAtoms_type_SPAposition = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAposition", /* tp_name */ + sizeof(ACIS_GeometricAtoms_SPAposition), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_GeometricAtoms_dealloc_SPAposition, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_GeometricAtoms_repr_SPAposition, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_GeometricAtoms_repr_SPAposition, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_GeometricAtoms_methods_SPAposition, /* tp_methods */ + ACIS_GeometricAtoms_members_SPAposition, /* tp_members */ + ACIS_GeometricAtoms_getseters_SPAposition, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_GeometricAtoms_init_SPAposition, /* tp_init */ + 0, /* tp_alloc */ + ACIS_GeometricAtoms_new_SPAposition, /* tp_new */ + }; + + +/** + * SPAvector wrapper + */ + +static void +ACIS_GeometricAtoms_dealloc_SPAvector(ACIS_GeometricAtoms_SPAvector *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_GeometricAtoms_new_SPAvector(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_GeometricAtoms_SPAvector *self; + + self = (ACIS_GeometricAtoms_SPAvector *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_GeometricAtoms_init_SPAvector(ACIS_GeometricAtoms_SPAvector *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + static char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAvector(input_x, input_y, input_z); + + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_repr_SPAvector(ACIS_GeometricAtoms_SPAvector *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAvector object (%s, %s, %s)", _x, _y, _z); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_component(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->component(_i)); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_set_component(ACIS_GeometricAtoms_SPAvector *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + static char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_component(_i, _new_c); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_set_x(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_set_y(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_set_z(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_x(ACIS_GeometricAtoms_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_y(ACIS_GeometricAtoms_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_z(ACIS_GeometricAtoms_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_x_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAvector_x(self); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_y_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAvector_y(self); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAvector_z_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAvector_z(self); +} + +static int +ACIS_GeometricAtoms_method_SPAvector_x_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAvector_set_x(self, value); + return 0; +} + +static int +ACIS_GeometricAtoms_method_SPAvector_y_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAvector_set_y(self, value); + return 0; +} + +static int +ACIS_GeometricAtoms_method_SPAvector_z_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAvector_set_z(self, value); + return 0; +} + +static PyGetSetDef + ACIS_GeometricAtoms_getseters_SPAvector[] = + { + { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAvector_x_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAvector_y_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAvector_z_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_GeometricAtoms_members_SPAvector[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_GeometricAtoms_methods_SPAvector[] = + { + { "component", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_GeometricAtoms_type_SPAvector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAvector", /* tp_name */ + sizeof(ACIS_GeometricAtoms_SPAvector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_GeometricAtoms_dealloc_SPAvector, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_GeometricAtoms_repr_SPAvector, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_GeometricAtoms_repr_SPAvector, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_GeometricAtoms_methods_SPAvector, /* tp_methods */ + ACIS_GeometricAtoms_members_SPAvector, /* tp_members */ + ACIS_GeometricAtoms_getseters_SPAvector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_GeometricAtoms_init_SPAvector, /* tp_init */ + 0, /* tp_alloc */ + ACIS_GeometricAtoms_new_SPAvector, /* tp_new */ + }; + + +/** + * SPAunit_vector wrapper + */ + +static void +ACIS_GeometricAtoms_dealloc_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_GeometricAtoms_new_SPAunit_vector(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_GeometricAtoms_SPAunit_vector *self; + + self = (ACIS_GeometricAtoms_SPAunit_vector *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_GeometricAtoms_init_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + static char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAunit_vector(input_x, input_y, input_z); + + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_repr_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAunit_vector object (%s, %s, %s)", _x, _y, _z); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_component(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->component(_i)); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_set_component(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + static char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_component(_i, _new_c); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_set_x(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_set_y(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_set_z(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_x(ACIS_GeometricAtoms_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_y(ACIS_GeometricAtoms_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_z(ACIS_GeometricAtoms_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_x_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAunit_vector_x(self); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_y_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAunit_vector_y(self); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAunit_vector_z_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) +{ + return ACIS_GeometricAtoms_method_SPAunit_vector_z(self); +} + +static int +ACIS_GeometricAtoms_method_SPAunit_vector_x_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAunit_vector_set_x(self, value); + return 0; +} + +static int +ACIS_GeometricAtoms_method_SPAunit_vector_y_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAunit_vector_set_y(self, value); + return 0; +} + +static int +ACIS_GeometricAtoms_method_SPAunit_vector_z_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) +{ + ACIS_GeometricAtoms_method_SPAunit_vector_set_z(self, value); + return 0; +} + +static PyGetSetDef + ACIS_GeometricAtoms_getseters_SPAunit_vector[] = + { + { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_x_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_y_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_z_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_GeometricAtoms_members_SPAunit_vector[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_GeometricAtoms_methods_SPAunit_vector[] = + { + { "component", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_GeometricAtoms_type_SPAunit_vector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAunit_vector", /* tp_name */ + sizeof(ACIS_GeometricAtoms_SPAunit_vector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_GeometricAtoms_dealloc_SPAunit_vector, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_GeometricAtoms_repr_SPAunit_vector, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_GeometricAtoms_repr_SPAunit_vector, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_GeometricAtoms_methods_SPAunit_vector, /* tp_methods */ + ACIS_GeometricAtoms_members_SPAunit_vector, /* tp_members */ + ACIS_GeometricAtoms_getseters_SPAunit_vector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_GeometricAtoms_init_SPAunit_vector, /* tp_init */ + 0, /* tp_alloc */ + ACIS_GeometricAtoms_new_SPAunit_vector, /* tp_new */ + }; + + +/** + * SPAmatrix wrapper + */ + +static void +ACIS_GeometricAtoms_dealloc_SPAmatrix(ACIS_GeometricAtoms_SPAmatrix *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_GeometricAtoms_new_SPAmatrix(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_GeometricAtoms_SPAmatrix *self; + + self = (ACIS_GeometricAtoms_SPAmatrix *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_GeometricAtoms_init_SPAmatrix(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAmatrix(); + + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_column(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *arg) +{ + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + // Create a new SPAvector python object + PyObject *_python_ret = _ACIS_new_SPAvector(); + + // Convert python input argument into a C variable + int _in_col = (int) PyLong_AsLong(arg); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((ACIS_GeometricAtoms_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->column(_in_col); + + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + // Return the updated python object + return _python_ret; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_row(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *arg) +{ + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + // Create a new SPAvector python object + PyObject *_python_ret = _ACIS_new_SPAvector(); + + // Convert python input argument into a C variable + int _in_row = (int) PyLong_AsLong(arg); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((ACIS_GeometricAtoms_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->row(_in_row); + + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + // Return the updated python object + return _python_ret; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_inverse(ACIS_GeometricAtoms_SPAmatrix *self) +{ + // Create a new SPAmatrix python object + PyObject *_python_ret = _ACIS_new_SPAmatrix(); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((ACIS_GeometricAtoms_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->inverse(); + + // Return the updated python object + return _python_ret; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_transpose(ACIS_GeometricAtoms_SPAmatrix *self) +{ + // Create a new SPAmatrix python object + PyObject *_python_ret = _ACIS_new_SPAmatrix(); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((ACIS_GeometricAtoms_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->transpose(); + + // Return the updated python object + return _python_ret; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_determinant(ACIS_GeometricAtoms_SPAmatrix *self) +{ + // Execute the ACIS function and return the value as a python object + return PyFloat_FromDouble(self->_acis_obj->determinant()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_element(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + int input_row, input_col; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "row", + (char *) "col", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_row, &input_col)) + return NULL; + + // Execute the ACIS function and return the value as a python object + return PyFloat_FromDouble(self->_acis_obj->element(input_row, input_col)); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_set_element(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + int input_row, input_col; + double input_new_e; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "row", + (char *) "col", + (char *) "new_e", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iid", kwlist, &input_row, &input_col, &input_new_e)) + return NULL; + + // Execute the ACIS function + self->_acis_obj->set_element(input_row, input_col, input_new_e); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAmatrix_is_identity(ACIS_GeometricAtoms_SPAmatrix *self) +{ + logical _ret_val = self->_acis_obj->is_identity(); + + if (_ret_val) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyGetSetDef + ACIS_GeometricAtoms_getseters_SPAmatrix[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_GeometricAtoms_members_SPAmatrix[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_GeometricAtoms_methods_SPAmatrix[] = + { + { "column", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_column, METH_O, "Extracts a column from this matrix" }, + { "row", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_row, METH_O, "Extracts a row from this matrix" }, + { "element", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, + { "set_element", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, + { "determinant", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_determinant, METH_NOARGS, "Returns the determinant of this matrix" }, + { "transpose", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_transpose, METH_NOARGS, "Returns a transpose of this matrix" }, + { "inverse", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_inverse, METH_NOARGS, "Returns the inverse of this matrix" }, + { "is_identity", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_GeometricAtoms_type_SPAmatrix = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAmatrix", /* tp_name */ + sizeof(ACIS_GeometricAtoms_SPAmatrix), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_GeometricAtoms_dealloc_SPAmatrix, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_GeometricAtoms_methods_SPAmatrix, /* tp_methods */ + ACIS_GeometricAtoms_members_SPAmatrix, /* tp_members */ + ACIS_GeometricAtoms_getseters_SPAmatrix, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_GeometricAtoms_init_SPAmatrix, /* tp_init */ + 0, /* tp_alloc */ + ACIS_GeometricAtoms_new_SPAmatrix, /* tp_new */ + }; + + +/** + * SPAtransf wrapper + */ + +static void +ACIS_GeometricAtoms_dealloc_SPAtransf(ACIS_GeometricAtoms_SPAtransf *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_GeometricAtoms_new_SPAtransf(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_GeometricAtoms_SPAtransf *self; + + self = (ACIS_GeometricAtoms_SPAtransf *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_GeometricAtoms_init_SPAtransf(ACIS_GeometricAtoms_SPAtransf *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAtransf(); + + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_affine(ACIS_GeometricAtoms_SPAtransf *self) +{ + PyObject *_ret = _ACIS_new_SPAmatrix(); + + *((ACIS_GeometricAtoms_SPAmatrix *) _ret)->_acis_obj = self->_acis_obj->affine(); + + return _ret; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_inverse(ACIS_GeometricAtoms_SPAtransf *self) +{ + PyObject *_ret = _ACIS_new_SPAtransf(); + + *((ACIS_GeometricAtoms_SPAtransf *) _ret)->_acis_obj = self->_acis_obj->inverse(); + + return _ret; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_translation(ACIS_GeometricAtoms_SPAtransf *self) +{ + PyObject *_ret = _ACIS_new_SPAvector(); + + *((ACIS_GeometricAtoms_SPAvector *) _ret)->_acis_obj = self->_acis_obj->translation(); + + return _ret; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_identity(ACIS_GeometricAtoms_SPAtransf *self) +{ + logical _check = self->_acis_obj->identity(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_reflect(ACIS_GeometricAtoms_SPAtransf *self) +{ + logical _check = self->_acis_obj->reflect(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_rotate(ACIS_GeometricAtoms_SPAtransf *self) +{ + logical _check = self->_acis_obj->rotate(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_scaling(ACIS_GeometricAtoms_SPAtransf *self) +{ + return PyFloat_FromDouble(self->_acis_obj->scaling()); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPAtransf_shear(ACIS_GeometricAtoms_SPAtransf *self) +{ + logical _check = self->_acis_obj->shear(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyGetSetDef + ACIS_GeometricAtoms_getseters_SPAtransf[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_GeometricAtoms_members_SPAtransf[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_GeometricAtoms_methods_SPAtransf[] = + { + { "affine", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_affine, METH_NOARGS, "Returns the affine portion of the transformation" }, + { "inverse", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_inverse, METH_NOARGS, "Returns the inverse transformation" }, + { "translation", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, + { "identity", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, + { "reflect", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, + { "rotate", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, + { "scaling", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, + { "shear", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_GeometricAtoms_type_SPAtransf = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(ACIS_GeometricAtoms_SPAtransf), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_GeometricAtoms_dealloc_SPAtransf, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAtransf represents a general 3D affine transformation", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_GeometricAtoms_methods_SPAtransf, /* tp_methods */ + ACIS_GeometricAtoms_members_SPAtransf, /* tp_members */ + ACIS_GeometricAtoms_getseters_SPAtransf, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_GeometricAtoms_init_SPAtransf, /* tp_init */ + 0, /* tp_alloc */ + ACIS_GeometricAtoms_new_SPAtransf, /* tp_new */ + }; + + +/** + * SPApar_pos wrapper + */ + +static void +ACIS_GeometricAtoms_dealloc_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_GeometricAtoms_new_SPApar_pos(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_GeometricAtoms_SPApar_pos *self; + + self = (ACIS_GeometricAtoms_SPApar_pos *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_GeometricAtoms_init_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPApar_pos(); + + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_repr_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self) +{ + double u = self->_acis_obj->u; double v = self->_acis_obj->v; + + char *_u = PyOS_double_to_string(u, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_u) + return PyErr_NoMemory(); + + char *_v = PyOS_double_to_string(v, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_v) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPApar_pos object (%s, %s)", _u, _v); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPApar_pos_u_getter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->u); +} + +static int +ACIS_GeometricAtoms_method_SPApar_pos_u_setter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) +{ + self->_acis_obj->u = PyFloat_AsDouble(value); + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPApar_pos_v_getter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->v); +} + +static int +ACIS_GeometricAtoms_method_SPApar_pos_v_setter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) +{ + self->_acis_obj->v = PyFloat_AsDouble(value); + return 0; +} + +static PyGetSetDef + ACIS_GeometricAtoms_getseters_SPApar_pos[] = + { + { (char *) "u", (getter) ACIS_GeometricAtoms_method_SPApar_pos_u_getter, (setter) ACIS_GeometricAtoms_method_SPApar_pos_u_setter, (char *) "value of the u parameter", NULL }, + { (char *) "v", (getter) ACIS_GeometricAtoms_method_SPApar_pos_v_getter, (setter) ACIS_GeometricAtoms_method_SPApar_pos_v_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_GeometricAtoms_members_SPApar_pos[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_GeometricAtoms_methods_SPApar_pos[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_GeometricAtoms_type_SPApar_pos = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(ACIS_GeometricAtoms_SPApar_pos), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_GeometricAtoms_dealloc_SPApar_pos, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_GeometricAtoms_repr_SPApar_pos, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_GeometricAtoms_repr_SPApar_pos, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_GeometricAtoms_methods_SPApar_pos, /* tp_methods */ + ACIS_GeometricAtoms_members_SPApar_pos, /* tp_members */ + ACIS_GeometricAtoms_getseters_SPApar_pos, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_GeometricAtoms_init_SPApar_pos, /* tp_init */ + 0, /* tp_alloc */ + ACIS_GeometricAtoms_new_SPApar_pos, /* tp_new */ + }; + + +/** + * SPApar_vec wrapper + */ + +static void +ACIS_GeometricAtoms_dealloc_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_GeometricAtoms_new_SPApar_vec(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_GeometricAtoms_SPApar_vec *self; + + self = (ACIS_GeometricAtoms_SPApar_vec *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_GeometricAtoms_init_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPApar_vec(); + + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_repr_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self) +{ + double du = self->_acis_obj->du; double dv = self->_acis_obj->dv; + + char *_du = PyOS_double_to_string(du, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_du) + return PyErr_NoMemory(); + + char *_dv = PyOS_double_to_string(dv, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_dv) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPApar_vec object (%s, %s)", _du, _dv); +} + +static PyObject * +ACIS_GeometricAtoms_method_SPApar_vec_du_getter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->du); +} + +static int +ACIS_GeometricAtoms_method_SPApar_vec_du_setter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) +{ + self->_acis_obj->du = PyFloat_AsDouble(value); + return 0; +} + +static PyObject * +ACIS_GeometricAtoms_method_SPApar_vec_dv_getter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->dv); +} + +static int +ACIS_GeometricAtoms_method_SPApar_vec_dv_setter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) +{ + self->_acis_obj->dv = PyFloat_AsDouble(value); + return 0; +} + +static PyGetSetDef + ACIS_GeometricAtoms_getseters_SPApar_vec[] = + { + { (char *) "du", (getter) ACIS_GeometricAtoms_method_SPApar_vec_du_getter, (setter) ACIS_GeometricAtoms_method_SPApar_vec_du_setter, (char *) "value of the u parameter", NULL }, + { (char *) "dv", (getter) ACIS_GeometricAtoms_method_SPApar_vec_dv_getter, (setter) ACIS_GeometricAtoms_method_SPApar_vec_dv_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_GeometricAtoms_members_SPApar_vec[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_GeometricAtoms_methods_SPApar_vec[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_GeometricAtoms_type_SPApar_vec = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(ACIS_GeometricAtoms_SPApar_vec), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_GeometricAtoms_dealloc_SPApar_vec, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) ACIS_GeometricAtoms_repr_SPApar_vec, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) ACIS_GeometricAtoms_repr_SPApar_vec, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_GeometricAtoms_methods_SPApar_vec, /* tp_methods */ + ACIS_GeometricAtoms_members_SPApar_vec, /* tp_members */ + ACIS_GeometricAtoms_getseters_SPApar_vec, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_GeometricAtoms_init_SPApar_vec, /* tp_init */ + 0, /* tp_alloc */ + ACIS_GeometricAtoms_new_SPApar_vec, /* tp_new */ + }; + +/** + * Python module definitions + */ + +static PyObject * +ACIS_GeometricAtoms_method_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_origin = NULL, *input_x_axis = NULL, *input_y_axis = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "new_origin", + (char *) "new_x_axis", + (char *) "new_y_axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_origin, &input_x_axis, &input_y_axis)) + return NULL; + + // Check inputs + if (!_ACIS_check_SPAposition(input_origin)) + { + PyErr_SetString(PyExc_TypeError, "First parameter (new_origin) must be a SPAposition object"); + return NULL; + } + + if (!_ACIS_check_SPAunit_vector(input_x_axis)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (new_x_axis) must be a SPAunit_vector object"); + return NULL; + } + + if (!_ACIS_check_SPAunit_vector(input_y_axis)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (new_y_axis) must be a SPAunit_vector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAposition *&_new_origin = ((ACIS_GeometricAtoms_SPAposition *) input_origin)->_acis_obj; + SPAunit_vector *&_new_x_axis = ((ACIS_GeometricAtoms_SPAunit_vector *) input_x_axis)->_acis_obj; + SPAunit_vector *&_new_y_axis = ((ACIS_GeometricAtoms_SPAunit_vector *) input_y_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = coordinate_transf(*_new_origin, *_new_x_axis, *_new_y_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_GeometricAtoms_method_make_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_affine = NULL, *input_translation = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "affine", + (char *) "translation", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_affine, &input_translation)) + return NULL; + + // Check inputs + if (!_ACIS_check_SPAmatrix(input_affine)) + { + PyErr_SetString(PyExc_TypeError, "First parameter (affine) must be a SPAmatrix object"); + return NULL; + } + + if (!_ACIS_check_SPAvector(input_translation)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (translate) must be a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAmatrix *&_affine = ((ACIS_GeometricAtoms_SPAmatrix *) input_affine)->_acis_obj; + SPAvector *&_translation = ((ACIS_GeometricAtoms_SPAvector *) input_translation)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = make_transf(*_affine, *_translation); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_GeometricAtoms_method_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_axis = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_axis)) + return NULL; + + // Check inputs + if (!_ACIS_check_SPAvector(input_axis)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_axis = ((ACIS_GeometricAtoms_SPAvector *) input_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = reflect_transf(*_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_GeometricAtoms_method_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_axis = NULL; + double input_angle; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "angle", + (char *) "axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dO", kwlist, &input_angle, &input_axis)) + return NULL; + + // Check inputs + if (!_ACIS_check_SPAvector(input_axis)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_axis = ((ACIS_GeometricAtoms_SPAvector *) input_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = rotate_transf(input_angle, *_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_GeometricAtoms_method_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL, *input_arg6 = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "scale", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOOO", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5, &input_arg6)) + return NULL; + + SPAtransf retval; + + if (!PyFloat_Check(input_arg1)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg1 = PyFloat_AsDouble(input_arg1); + + if (input_arg2 != NULL || input_arg3 != NULL) + { + if (!PyFloat_Check(input_arg2) && !PyFloat_Check(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg2 = PyFloat_AsDouble(input_arg2); + double _arg3 = PyFloat_AsDouble(input_arg3); + + if (input_arg4 != NULL || input_arg5 != NULL || input_arg6 != NULL) + { + if (!PyFloat_Check(input_arg4) && !PyFloat_Check(input_arg5) && !PyFloat_Check(input_arg5)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg4 = PyFloat_AsDouble(input_arg4); + double _arg5 = PyFloat_AsDouble(input_arg5); + double _arg6 = PyFloat_AsDouble(input_arg5); + + retval = scale_transf(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6); + } + else + { + retval = scale_transf(_arg1, _arg2, _arg3); + } + } + else + { + retval = scale_transf(_arg1); + } + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_GeometricAtoms_method_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double _shear_xy, _shear_xz, _shear_yz; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "shearxy", + (char *) "shearxz", + (char *) "shearyz", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddd", kwlist, &_shear_xy, &_shear_xz, &_shear_yz)) + return NULL; + + // Execute ACIS function + SPAtransf retval = shear_transf(_shear_xy, _shear_xz, _shear_yz); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_GeometricAtoms_method_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_disp = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "disp", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_disp)) + return NULL; + + // "disp" must be a SPAvector object + if (!_ACIS_check_SPAvector(input_disp)) + { + PyErr_SetString(PyExc_TypeError, "Expecting SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_disp = ((ACIS_GeometricAtoms_SPAvector *) input_disp)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = translate_transf(*_disp); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_GeometricAtoms_method_angle_between(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL, *input_z = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "z", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist, &input_v1, &input_v2, &input_z)) + return NULL; + + // Set return value + double _retval; + + // SPAvector scenario + if (_ACIS_check_SPAvector(input_v1)) + { + if (!_ACIS_check_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; + + if (input_z != NULL) + { + if (!_ACIS_check_SPAvector(input_z)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_z = ((ACIS_GeometricAtoms_SPAunit_vector *) input_z)->_acis_obj; + + _retval = angle_between(*_v1, *_v2, *_z); + } + else + { + _retval = angle_between(*_v1, *_v2); + } + } + else if (_ACIS_check_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_ACIS_check_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_z != NULL) + { + if (!_ACIS_check_SPAunit_vector(input_z)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_z = ((ACIS_GeometricAtoms_SPAunit_vector *) input_z)->_acis_obj; + + _retval = angle_between(*_v1, *_v2, *_z); + } + else + { + _retval = angle_between(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return PyFloat object + return PyFloat_FromDouble(_retval); +} + +static PyObject * +ACIS_GeometricAtoms_method_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + double input_res = -1.0; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "res", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_ACIS_check_SPAvector(input_v1)) + { + if (!_ACIS_check_SPAvector(input_v2) || !_ACIS_check_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = antiparallel(*_v1, *_v2, input_res); + } + else + { + _retval = antiparallel(*_v1, *_v2); + } + } + else if (_ACIS_check_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_ACIS_check_SPAunit_vector(input_v2) || !_ACIS_check_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector or SPAvector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = antiparallel(*_v1, *_v2, input_res); + } + else + { + _retval = antiparallel(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +static PyObject * +ACIS_GeometricAtoms_method_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + int input_same_dir = 0; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "same_dir", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i", kwlist, &input_v1, &input_v2, &input_same_dir)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_ACIS_check_SPAvector(input_v1)) + { + if (!_ACIS_check_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; + + _retval = are_parallel(*_v1, *_v2, input_same_dir); + } + else if (_ACIS_check_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_ACIS_check_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; + + _retval = are_parallel(*_v1, *_v2, input_same_dir); + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +static PyObject * +ACIS_GeometricAtoms_method_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_v1, &input_v2)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_ACIS_check_SPAvector(input_v1)) + { + if (!_ACIS_check_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; + + _retval = are_perpendicular(*_v1, *_v2); + } + else if (_ACIS_check_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_ACIS_check_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; + + _retval = are_perpendicular(*_v1, *_v2); + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +static PyObject * +ACIS_GeometricAtoms_method_biparallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + double input_res = -1.0; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "res", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_ACIS_check_SPAvector(input_v1)) + { + if (!_ACIS_check_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = biparallel(*_v1, *_v2, input_res); + } + else + { + _retval = biparallel(*_v1, *_v2); + } + } + else if (_ACIS_check_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_ACIS_check_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = biparallel(*_v1, *_v2, input_res); + } + else + { + _retval = biparallel(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +static PyObject * +ACIS_GeometricAtoms_method_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_ang; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "ang", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) + return NULL; + + double _retval = degrees_to_radians(input_ang); + + // Return double + return PyFloat_FromDouble(_retval); +} + +static PyObject * +ACIS_GeometricAtoms_method_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_ang; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "ang", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) + return NULL; + + double _retval = radians_to_degrees(input_ang); + + // Return double + return PyFloat_FromDouble(_retval); +} + +static PyObject * +ACIS_GeometricAtoms_method_get_resabs(PyObject *self) +{ + return PyFloat_FromDouble(get_resabs()); +} + +static PyObject * +ACIS_GeometricAtoms_method_get_resfit(PyObject *self) +{ + return PyFloat_FromDouble(get_resfit()); +} + +static PyObject * +ACIS_GeometricAtoms_method_get_resmch(PyObject *self) +{ + return PyFloat_FromDouble(get_resmch()); +} + +static PyObject * +ACIS_GeometricAtoms_method_get_resnor(PyObject *self) +{ + return PyFloat_FromDouble(get_resnor()); +} + +static PyObject * +ACIS_GeometricAtoms_method_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) + return NULL; + + if (!_ACIS_check_SPAposition(input_pt1) || !_ACIS_check_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); + return NULL; + } + + SPAposition *&_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; + SPAposition *&_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; + + // Return double + return PyFloat_FromDouble(distance_to_point(*_pt1, *_pt2)); +} + +static PyObject * +ACIS_GeometricAtoms_method_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) + return NULL; + + if (!_ACIS_check_SPAposition(input_pt1) || !_ACIS_check_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); + return NULL; + } + + SPAposition *&_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; + SPAposition *&_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; + + // Return double + return PyFloat_FromDouble(distance_to_point_squared(*_pt1, *_pt2)); +} + +static PyMethodDef + module_methods[] = + { + { "coordinate_transf", (PyCFunction) ACIS_GeometricAtoms_method_coordinate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a coordinate transformation" }, + { "make_transf", (PyCFunction) ACIS_GeometricAtoms_method_make_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation retrieving the needed information from the provided transformation matrix and the scaling vector" }, + { "reflect_transf", (PyCFunction) ACIS_GeometricAtoms_method_reflect_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a reflection through a plane, specified by its normal" }, + { "rotate_transf", (PyCFunction) ACIS_GeometricAtoms_method_rotate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a simple rotation by an angle about a given axis" }, + { "scale_transf", (PyCFunction) ACIS_GeometricAtoms_method_scale_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a scale transformation (uniform, non-uniform and shear)" }, + { "shear_transf", (PyCFunction) ACIS_GeometricAtoms_method_shear_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a shear transformation" }, + { "translate_transf", (PyCFunction) ACIS_GeometricAtoms_method_translate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a translation by a given vector" }, + { "angle_between", (PyCFunction) ACIS_GeometricAtoms_method_angle_between, METH_VARARGS | METH_KEYWORDS, "Calculates the angle between two vectors or unit vectors" }, + { "antiparallel", (PyCFunction) ACIS_GeometricAtoms_method_antiparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are anti-parallel" }, + { "are_parallel", (PyCFunction) ACIS_GeometricAtoms_method_are_parallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are parallel" }, + { "are_perpendicular", (PyCFunction) ACIS_GeometricAtoms_method_are_perpendicular, METH_VARARGS | METH_KEYWORDS, " Determines if two vectors or unit vectors are perpendicular" }, + { "biparallel", (PyCFunction) ACIS_GeometricAtoms_method_biparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are bi-parallel" }, + { "degrees_to_radians", (PyCFunction) ACIS_GeometricAtoms_method_degrees_to_radians, METH_VARARGS | METH_KEYWORDS, "Converts an angle from degrees to radians" }, + { "radians_to_degrees", (PyCFunction) ACIS_GeometricAtoms_method_radians_to_degrees, METH_VARARGS | METH_KEYWORDS, "Converts an angle from radians to degrees" }, + { "get_resabs", (PyCFunction) ACIS_GeometricAtoms_method_get_resabs, METH_NOARGS, "Gets the SPAresabs resolution" }, + { "get_resfit", (PyCFunction) ACIS_GeometricAtoms_method_get_resfit, METH_NOARGS, "Gets the SPAresfit resolution" }, + { "get_resmch", (PyCFunction) ACIS_GeometricAtoms_method_get_resmch, METH_NOARGS, "Gets the resmch resolution" }, + { "get_resnor", (PyCFunction) ACIS_GeometricAtoms_method_get_resnor, METH_NOARGS, "Gets the SPAresnor resolution" }, + { "distance_to_point", (PyCFunction) ACIS_GeometricAtoms_method_distance_to_point, METH_VARARGS | METH_KEYWORDS, "Determines the distance between two points" }, + { "distance_to_point_squared", (PyCFunction) ACIS_GeometricAtoms_method_distance_to_point_squared, METH_VARARGS | METH_KEYWORDS, "\tComputes the squared distance between two positions" }, + { NULL, NULL, 0, NULL } + }; + +// Module documentation can be accessible via __doc__ +const char *module_name = "GeometricAtoms"; +const char *module_documentation = "Contains 3D ACIS Modeler geometric atoms, e.g. SPAposition, SPApar_pos, etc."; + +static struct PyModuleDef + ACIS_GeometricAtoms_module = + { + PyModuleDef_HEAD_INIT, + module_name, // name of the module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + module_methods + }; + +PyMODINIT_FUNC +PyInit_GeometricAtoms(void) +{ + PyObject *m; + m = PyModule_Create(&ACIS_GeometricAtoms_module); + if (m == NULL) + return NULL; + + // SPAposition + if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAposition) < 0) + return NULL; + Py_INCREF(&ACIS_GeometricAtoms_type_SPAposition); + PyModule_AddObject(m, "SPAposition", (PyObject *) &ACIS_GeometricAtoms_type_SPAposition); + + // SPAtransf + if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAtransf) < 0) + return NULL; + Py_INCREF(&ACIS_GeometricAtoms_type_SPAtransf); + PyModule_AddObject(m, "SPAtransf", (PyObject *) &ACIS_GeometricAtoms_type_SPAtransf); + + // SPAmatrix + if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAmatrix) < 0) + return NULL; + Py_INCREF(&ACIS_GeometricAtoms_type_SPAmatrix); + PyModule_AddObject(m, "SPAmatrix", (PyObject *) &ACIS_GeometricAtoms_type_SPAmatrix); + + // SPAvector + if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAvector) < 0) + return NULL; + Py_INCREF(&ACIS_GeometricAtoms_type_SPAvector); + PyModule_AddObject(m, "SPAvector", (PyObject *) &ACIS_GeometricAtoms_type_SPAvector); + + // SPAunit_vector + if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAunit_vector) < 0) + return NULL; + Py_INCREF(&ACIS_GeometricAtoms_type_SPAunit_vector); + PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &ACIS_GeometricAtoms_type_SPAunit_vector); + + // SPApar_pos + if (PyType_Ready(&ACIS_GeometricAtoms_type_SPApar_pos) < 0) + return NULL; + Py_INCREF(&ACIS_GeometricAtoms_type_SPApar_pos); + PyModule_AddObject(m, "SPApar_pos", (PyObject *) &ACIS_GeometricAtoms_type_SPApar_pos); + + // SPApar_vec + if (PyType_Ready(&ACIS_GeometricAtoms_type_SPApar_vec) < 0) + return NULL; + Py_INCREF(&ACIS_GeometricAtoms_type_SPApar_vec); + PyModule_AddObject(m, "SPApar_vec", (PyObject *) &ACIS_GeometricAtoms_type_SPApar_vec); + + return m; +} + +bool _ACIS_check_SPAposition(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAposition; +} + +PyObject *_ACIS_new_SPAposition() +{ + return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAposition, NULL); +} + +bool _ACIS_check_SPAvector(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAvector; +} + +PyObject *_ACIS_new_SPAvector() +{ + return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAvector, NULL); +} + +bool _ACIS_check_SPAunit_vector(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAunit_vector; +} + +PyObject *_ACIS_new_SPAunit_vector() +{ + return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAunit_vector, NULL); +} + +bool _ACIS_check_SPAmatrix(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAmatrix; +} + +PyObject *_ACIS_new_SPAmatrix() +{ + return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAmatrix, NULL); +} + +bool _ACIS_check_SPAtransf(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAtransf; +} + +PyObject *_ACIS_new_SPAtransf() +{ + return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAtransf, NULL); +} + +bool _ACIS_check_SPApar_pos(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPApar_pos; +} + +PyObject *_ACIS_new_SPApar_pos() +{ + return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPApar_pos, NULL); +} + +bool _ACIS_check_SPApar_vec(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPApar_vec; +} + +PyObject *_ACIS_new_SPApar_vec() +{ + return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPApar_vec, NULL); +} diff --git a/src/acis_geometric_atoms.h b/src/acis_geometric_atoms.h new file mode 100644 index 0000000..ce4ef8a --- /dev/null +++ b/src/acis_geometric_atoms.h @@ -0,0 +1,114 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef ACIS_GEOMETRIC_ATOMS_H +#define ACIS_GEOMETRIC_ATOMS_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "acis_geometric_atoms_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Define SPAposition +typedef struct +{ + PyObject_HEAD + SPAposition *_acis_obj; +} ACIS_GeometricAtoms_SPAposition; + +PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAposition(); + +bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAposition(PyObject *ob); + +// Define SPAvector +typedef struct +{ + PyObject_HEAD + SPAvector *_acis_obj; +} ACIS_GeometricAtoms_SPAvector; + +PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAvector(); + +bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAvector(PyObject *ob); + +// Define SPAunit_vector +typedef struct +{ + PyObject_HEAD + SPAunit_vector *_acis_obj; +} ACIS_GeometricAtoms_SPAunit_vector; + +PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAunit_vector(); + +bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAunit_vector(PyObject *ob); + +// Define SPAmatrix +typedef struct +{ + PyObject_HEAD + SPAmatrix *_acis_obj; +} ACIS_GeometricAtoms_SPAmatrix; + +PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAmatrix(); + +bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAmatrix(PyObject *ob); + +// Define SPAtransf +typedef struct +{ + PyObject_HEAD + SPAtransf *_acis_obj; +} ACIS_GeometricAtoms_SPAtransf; + +PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAtransf(); + +bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAtransf(PyObject *ob); + +// Define SPApar_pos +typedef struct +{ + PyObject_HEAD + SPApar_pos *_acis_obj; +} ACIS_GeometricAtoms_SPApar_pos; + +PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPApar_pos(); + +bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPApar_pos(PyObject *ob); + +// Define SPApar_vec +typedef struct +{ + PyObject_HEAD + SPApar_vec *_acis_obj; +} ACIS_GeometricAtoms_SPApar_vec; + +PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPApar_vec(); + +bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPApar_vec(PyObject *ob); + +#ifdef __cplusplus +} +#endif + +#endif // !ACIS_GEOMETRIC_ATOMS_H diff --git a/src/acis_includes.h b/src/acis_includes.h deleted file mode 100644 index f986116..0000000 --- a/src/acis_includes.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef A3DPY_INCLUDES_H -#define A3DPY_INCLUDES_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#endif // !A3DPY_INCLUDES_H diff --git a/src/acis_licensing.cpp b/src/acis_licensing.cpp new file mode 100644 index 0000000..486d06f --- /dev/null +++ b/src/acis_licensing.cpp @@ -0,0 +1,61 @@ +#include + +#include +#include +#include + + +static PyObject * +ACIS_spa_unlock_products(PyObject *self, PyObject *arg) +{ + // Check if the input is a string + if (!PyUnicode_Check(arg)) + { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; + } + + // Convert PyObject to C-style string + const char *unlock_str = PyUnicode_AsUTF8(arg); + + // Call ACIS Licensing API + spa_unlock_result out = spa_unlock_products(unlock_str); + + // If license is good, then return True. Otherwise, return the licensing error message + if (SPA_UNLOCK_PASS == out.get_state()) + Py_RETURN_TRUE; + else + return PyUnicode_FromString(out.get_message_text()); +} + +static PyMethodDef + ACIS_Licensing_methods[] = + { + { "spa_unlock_products", (PyCFunction) ACIS_spa_unlock_products, METH_O, "Unlock the 3D ACIS Modeler using the license key" }, + { NULL, NULL, 0, NULL } + }; + +// Module documentation can be accessible via __doc__ +const char *module_documentation = "Contains 3D ACIS Modeler licensing API related functions and classes"; + +static struct PyModuleDef + ACIS_Licensing_module = + { + PyModuleDef_HEAD_INIT, + "Licensing", // name of module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + ACIS_Licensing_methods + }; + +PyMODINIT_FUNC +PyInit_Licensing(void) +{ + PyObject *m; + + m = PyModule_Create(&ACIS_Licensing_module); + if (m == NULL) + return NULL; + + return m; +} diff --git a/src/acis_lists.cpp b/src/acis_lists.cpp new file mode 100644 index 0000000..7166971 --- /dev/null +++ b/src/acis_lists.cpp @@ -0,0 +1,440 @@ +#include "acis_lists.h" + + +/** + * 3D ACIS Modeler - ENTITY_LIST wrapper + */ + +static void +ACIS_Lists_dealloc_ENTITY_LIST(ACIS_Lists_ENTITY_LIST *self) +{ + // First, clear the contents of the ENTITY_LIST instance + self->_acis_obj->clear(); + + // Use ACIS_DELETE macro for ENTITY_LIST + ACIS_DELETE self->_acis_obj; + + // Delete the python object itself + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_Lists_new_ENTITY_LIST(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_Lists_ENTITY_LIST *self; + + self = (ACIS_Lists_ENTITY_LIST *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_Lists_init_ENTITY_LIST(ACIS_Lists_ENTITY_LIST *self) +{ + // ENTITY_LIST takes no arguments, so parsing is necessary + self->_acis_obj = ACIS_NEW ENTITY_LIST(); + return 0; +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_init(ACIS_Lists_ENTITY_LIST *self) +{ + self->_acis_obj->init(); + Py_RETURN_NONE; +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_clear(ACIS_Lists_ENTITY_LIST *self) +{ + self->_acis_obj->clear(); + Py_RETURN_NONE; +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_add(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + int index = -1; + + if (!_ACIS_check_ENTITY(arg)) + { + if (!_ACIS_check_ENTITY_LIST(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY or ENTITY_LIST object"); + return NULL; + } + else + { + // This function returns void + self->_acis_obj->add(*((ACIS_Lists_ENTITY_LIST *) arg)->_acis_obj); + } + } + else + { + // This function returns the added ENTITY's index number + index = self->_acis_obj->add(((ACIS_Entity_ENTITY *) arg)->_acis_obj); + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + if (index != -1) + { + return PyLong_FromLong(index); + } + else + { + Py_RETURN_NONE; + } +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_remove(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + int index = -1; + + if (!_ACIS_check_ENTITY(arg)) + { + if (!_ACIS_check_ENTITY_LIST(arg)) + { + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY, an ENTITY_LIST or an integer object"); + return NULL; + } + else + { + // This function returns the index number + index = self->_acis_obj->remove((int) PyLong_AsLong(arg)); + } + } + else + { + // This function returns void + self->_acis_obj->remove(*((ACIS_Lists_ENTITY_LIST *) arg)->_acis_obj); + } + } + else + { + // This function returns the removed ENTITY's index number + index = self->_acis_obj->remove(((ACIS_Entity_ENTITY *) arg)->_acis_obj); + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + if (index != -1) + { + return PyLong_FromLong(index); + } + else + { + Py_RETURN_NONE; + } +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_count(ACIS_Lists_ENTITY_LIST *self) +{ + return PyLong_FromLong(self->_acis_obj->count()); +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_iteration_count(ACIS_Lists_ENTITY_LIST *self) +{ + return PyLong_FromLong(self->_acis_obj->iteration_count()); +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_reverse(ACIS_Lists_ENTITY_LIST *self) +{ + self->_acis_obj->reverse(); + Py_RETURN_NONE; +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_lookup(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + if (!_ACIS_check_ENTITY(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY object"); + return NULL; + } + + int index = self->_acis_obj->lookup(((ACIS_Entity_ENTITY *) arg)->_acis_obj); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + return PyLong_FromLong(index); +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_byte_count(ACIS_Lists_ENTITY_LIST *self) +{ + return PyLong_FromLong(self->_acis_obj->byte_count()); +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_first(ACIS_Lists_ENTITY_LIST *self) +{ + ENTITY *_elem = self->_acis_obj->first(); + PyObject *retobj = __convert_entity(_elem); + return retobj; +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_next(ACIS_Lists_ENTITY_LIST *self) +{ + PyObject *retobj; + ENTITY *_elem = self->_acis_obj->next(); + + if (_elem) + { + retobj = __convert_entity(_elem); + } + else + { + // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + return retobj; +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_next_from(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) +{ + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an integer object"); + return NULL; + } + + Py_INCREF(arg); + int _from_index = (int) PyLong_AsLong(arg); + Py_DECREF(arg); + + PyObject *retobj; + ENTITY *_elem = self->_acis_obj->next_from(_from_index); + + if (_elem) + { + retobj = __convert_entity(_elem); + } + else + { + // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + return retobj; +} + +static PyObject * +ACIS_Lists_method_ENTITY_LIST_array(ACIS_Lists_ENTITY_LIST *self) +{ + /* This function will create a Python generator/iterator */ + + // Reference increment is necessary, otherwise this ENTITY_LIST will be garbage collected + Py_INCREF(self); + + // Iterator/Generator creation functions always return self! + return (PyObject *) self; +} + +static PyObject * +ACIS_Lists_iter_ENTITY_LIST(PyObject *self) +{ + /* Must have the same signature as PyObject_GetIter() */ + + // Move the ENTITY_LIST pointer to the beginning + ACIS_Lists_method_ENTITY_LIST_init((ACIS_Lists_ENTITY_LIST *) self); + + Py_INCREF(self); + return self; +} + +static PyObject * +ACIS_Lists_iter_next_ENTITY_LIST(PyObject *self) +{ + /* Must have the same signature as PyIter_Next() */ + + // Convert the input argument to a ENTITY_LIST object + ACIS_Lists_ENTITY_LIST *_ent_list = (ACIS_Lists_ENTITY_LIST *) self; + + // Return the next element + return ACIS_Lists_method_ENTITY_LIST_next(_ent_list); +} + +static PyGetSetDef + ACIS_Lists_getseters_ENTITY_LIST[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Lists_members_ENTITY_LIST[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Lists_methods_ENTITY_LIST[] = + { + { "add", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_add, METH_O, "Adds an entity or entities to the list" }, + { "remove", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_remove, METH_O, "Removes an entity or entities from the list" }, + { "count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, + { "iteration_count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, + { "init", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_init, METH_NOARGS, "Adds an entity or entities to the list" }, + { "lookup", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_lookup, METH_O, "Adds an entity or entities to the list" }, + { "reverse", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_reverse, METH_NOARGS, "Adds an entity or entities to the list" }, + { "byte_count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, + { "first", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, + { "next", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_next, METH_NOARGS, "Returns the next undeleted (live) entry" }, + { "next_from", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, + { "array", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Lists_type_ENTITY_LIST = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.ENTITY_LIST", /* tp_name */ + sizeof(ACIS_Lists_ENTITY_LIST), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_Lists_dealloc_ENTITY_LIST, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS ENTITY_LIST class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc) ACIS_Lists_iter_ENTITY_LIST, /* tp_iter */ + (iternextfunc) ACIS_Lists_iter_next_ENTITY_LIST, /* tp_iternext */ + ACIS_Lists_methods_ENTITY_LIST, /* tp_methods */ + ACIS_Lists_members_ENTITY_LIST, /* tp_members */ + ACIS_Lists_getseters_ENTITY_LIST, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Lists_init_ENTITY_LIST, /* tp_init */ + 0, /* tp_alloc */ + ACIS_Lists_new_ENTITY_LIST, /* tp_new */ + }; + + +/* + * Python Module Definitions + */ + +// Module documentation can be accessible via __doc__ +const char *module_name = "Lists"; +const char *module_documentation = "Contains 3D ACIS Modeler lists and containers, such as ENTITY_LIST"; + +static PyModuleDef + ACIS_Lists_module = + { + PyModuleDef_HEAD_INIT, + module_name, + module_documentation, + -1, + NULL, NULL, NULL, NULL, NULL + }; + +PyMODINIT_FUNC +PyInit_Lists(void) +{ + // Create a Python module, ACIS.Objects + PyObject *m; + m = PyModule_Create(&ACIS_Lists_module); + if (m == NULL) + return NULL; + + // Initialize ACIS ENTITY_LIST class as a Python type + if (PyType_Ready(&ACIS_Lists_type_ENTITY_LIST) < 0) + return NULL; + + // Increase the reference counter of the ENTITY_LIST type + Py_INCREF(&ACIS_Lists_type_ENTITY_LIST); + + // Add ENTITY_LIST type to the Objects module + PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &ACIS_Lists_type_ENTITY_LIST); + + // Return the module and all included objects + return m; +} + +PyObject *_ACIS_new_ENTITY_LIST() +{ + return PyObject_CallObject((PyObject *) &ACIS_Lists_type_ENTITY_LIST, NULL); +} + +bool _ACIS_check_ENTITY_LIST(PyObject *ob) +{ + if (Py_TYPE(ob) == &ACIS_Lists_type_ENTITY_LIST) + return true; + else + return false; +} + +PyObject *__convert_entity(ENTITY *ent) +{ + // Find the type name of the entity + const char *_type_name = ent->type_name(); + + // We could use a hashing function here... + PyObject *_retobj; + if (strcmp("body", _type_name) == 0) + { + _retobj = _ACIS_new_BODY(); + _ACIS_set_entity(_retobj, ent); + } + else if (strcmp("face", _type_name) == 0) + { + _retobj = _ACIS_new_FACE(); + _ACIS_set_entity(_retobj, ent); + } + else if (strcmp("surface", _type_name) == 0) + { + _retobj = _ACIS_new_SURFACE(); + _ACIS_set_entity(_retobj, ent); + } + + return _retobj; +} diff --git a/src/acis_lists.h b/src/acis_lists.h new file mode 100644 index 0000000..1838e70 --- /dev/null +++ b/src/acis_lists.h @@ -0,0 +1,46 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef ACIS_LISTS_H +#define ACIS_LISTS_H + +#include +#include + +#include + +#include "acis_entity.h" + +#include "acis_lists_export.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// Define ENTITY_LIST +typedef struct +{ + PyObject_HEAD + ENTITY_LIST *_acis_obj; +} ACIS_Lists_ENTITY_LIST; + +PyObject ACIS_LISTS_EXPORT *_ACIS_new_ENTITY_LIST(); + +bool ACIS_LISTS_EXPORT _ACIS_check_ENTITY_LIST(PyObject *ob); + +PyObject ACIS_LISTS_EXPORT *__convert_entity(ENTITY *ent); + +#ifdef __cplusplus +} +#endif + +#endif // !ACIS_LISTS_H diff --git a/src/acis_modeler.cpp b/src/acis_modeler.cpp index 3d3d0f0..a93f873 100644 --- a/src/acis_modeler.cpp +++ b/src/acis_modeler.cpp @@ -1,313 +1,705 @@ #include "acis_modeler.h" -const char *module_name = "Modeler"; -const char *module_documentation = "3D ACIS Modeler"; +bool disabled_acis_freelisting = false; -static PyMethodDef - module_methods[] = +static PyObject * +ACIS_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_n = 0; + int input_freelisting = 1; + + // List of keyword arguments that this function can take + static char *kwlist[] = { - { "spa_unlock_products", (PyCFunction) a3dp_spa_unlock_products, METH_O, "Unlock the 3D ACIS Modeler using the license key" }, - { "api_start_modeller", (PyCFunction) a3dp_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Starts the 3D ACIS Modeler" }, - { "api_stop_modeller", (PyCFunction) a3dp_api_stop_modeller, METH_NOARGS, "Stops the 3D ACIS Modeler" }, - { "is_modeler_started", (PyCFunction) a3dp_is_modeler_started, METH_NOARGS, "Checks if the 3D ACIS Modeler started" }, - { "api_start_modeler", (PyCFunction) a3dp_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Alternative way to call api_start_modeller()" }, - { "api_stop_modeler", (PyCFunction) a3dp_api_stop_modeller, METH_NOARGS, "Alternative way to call api_stop_modeller()" }, - { "api_save_entity_list", (PyCFunction) a3dp_api_save_entity_list, METH_VARARGS | METH_KEYWORDS, "Writes entities to a file in text or binary format" }, - { "api_set_file_info", (PyCFunction) a3dp_api_set_file_info, METH_VARARGS | METH_KEYWORDS, "Sets required header info to be written to ACIS save files" }, - { "api_get_file_info", (PyCFunction) a3dp_api_get_file_info, METH_O | METH_KEYWORDS, "Gets header info from the last restored file" }, - { "api_save_version", (PyCFunction) a3dp_api_save_version, METH_VARARGS | METH_KEYWORDS, "Sets the save file format" }, - { "api_set_dbl_option", (PyCFunction) a3dp_api_set_dbl_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given double" }, - { "api_set_int_option", (PyCFunction) a3dp_api_set_int_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given integer" }, - { "api_set_str_option", (PyCFunction) a3dp_api_set_str_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given string" }, - { "api_solid_block", (PyCFunction) a3dp_api_solid_block, METH_VARARGS | METH_KEYWORDS, "Creates a solid block given two positions on a diagonal of the block" }, - { "api_make_cuboid", (PyCFunction) a3dp_api_make_cuboid, METH_VARARGS | METH_KEYWORDS, "Creates cuboid of given width (x), depth (y) and height (z)" }, - { "api_make_frustum", (PyCFunction) a3dp_api_make_frustum, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical cone or cylinder of given height and radii" }, - { "api_make_prism", (PyCFunction) a3dp_api_make_prism, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical prism of given height, radii, and number of sides" }, - { "api_make_pyramid", (PyCFunction) a3dp_api_make_pyramid, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical pyramid of given height, radii, and number of sides" }, - { "api_make_sphere", (PyCFunction) a3dp_api_make_sphere, METH_VARARGS | METH_KEYWORDS, "Creates a sphere of given radius, centered at the origin" }, - { "api_make_torus", (PyCFunction) a3dp_api_make_torus, METH_VARARGS | METH_KEYWORDS, "Creates a torus of given major and minor radii centered at the origin" }, - { "api_apply_transf", (PyCFunction) a3dp_api_apply_transf, METH_VARARGS | METH_KEYWORDS, "Changes the transform entity attached to a body" }, - { "api_remove_transf", (PyCFunction) a3dp_api_remove_transf, METH_VARARGS | METH_KEYWORDS, "Removes (discards) the transformation of a body" }, - { "api_sheet_from_ff", (PyCFunction) a3dp_api_sheet_from_ff, METH_VARARGS | METH_KEYWORDS, "Creates a sheet body as a copy of a face" }, - { "api_unite", (PyCFunction) a3dp_api_unite, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean unite operation" }, - { "api_intersect", (PyCFunction) a3dp_api_intersect, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean intersect operation on two bodies" }, - { "api_subtract", (PyCFunction) a3dp_api_subtract, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean subtract operation" }, - { "api_imprint", (PyCFunction) a3dp_api_imprint, METH_VARARGS | METH_KEYWORDS, "Intersects two bodies and imprints the intersection graph on both bodies" }, - { "api_boolean_chop_body", (PyCFunction) a3dp_api_boolean_chop_body, METH_VARARGS | METH_KEYWORDS, "Executes simultaneous Boolean intersect and subtract operations on two bodies" }, - { "api_make_sweep_path", (PyCFunction) a3dp_api_make_sweep_path, METH_VARARGS | METH_KEYWORDS, "Constructs a path useful for creating a swept surface" }, - { "api_sweep_with_options", (PyCFunction) a3dp_api_sweep_with_options, METH_VARARGS | METH_KEYWORDS, "Sweeps the given profile along an edge, a distance, a vector or an axis" }, - { "get_owner_transf", (PyCFunction) a3dp_get_owner_transf, METH_VARARGS | METH_KEYWORDS, "Gets a copy of the SPAtransf from the owner of an ENTITY" }, - { "api_get_faces", (PyCFunction) a3dp_api_get_faces, METH_VARARGS | METH_KEYWORDS, "Gets all faces related to an entity" }, - { "api_get_edges", (PyCFunction) a3dp_api_get_edges, METH_VARARGS | METH_KEYWORDS, "Gets all the edges related to an entity" }, - { "coordinate_transf", (PyCFunction) a3dp_coordinate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a coordinate transformation" }, - { "make_transf", (PyCFunction) a3dp_make_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation retrieving the needed information from the provided transformation matrix and the scaling vector" }, - { "reflect_transf", (PyCFunction) a3dp_reflect_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a reflection through a plane, specified by its normal" }, - { "rotate_transf", (PyCFunction) a3dp_rotate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a simple rotation by an angle about a given axis" }, - { "scale_transf", (PyCFunction) a3dp_scale_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a scale transformation (uniform, non-uniform and shear)" }, - { "shear_transf", (PyCFunction) a3dp_shear_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a shear transformation" }, - { "translate_transf", (PyCFunction) a3dp_translate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a translation by a given vector" }, - { "angle_between", (PyCFunction) a3dp_angle_between, METH_VARARGS | METH_KEYWORDS, "Calculates the angle between two vectors or unit vectors" }, - { "antiparallel", (PyCFunction) a3dp_antiparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are anti-parallel" }, - { "are_parallel", (PyCFunction) a3dp_are_parallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are parallel" }, - { "are_perpendicular", (PyCFunction) a3dp_are_perpendicular, METH_VARARGS | METH_KEYWORDS, " Determines if two vectors or unit vectors are perpendicular" }, - { "biparallel", (PyCFunction) a3dp_biparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are bi-parallel" }, - { "degrees_to_radians", (PyCFunction) a3dp_degrees_to_radians, METH_VARARGS | METH_KEYWORDS, "Converts an angle from degrees to radians" }, - { "radians_to_degrees", (PyCFunction) a3dp_radians_to_degrees, METH_VARARGS | METH_KEYWORDS, "Converts an angle from radians to degrees" }, - { "get_resabs", (PyCFunction) a3dp_get_resabs, METH_NOARGS, "Gets the SPAresabs resolution" }, - { "get_resfit", (PyCFunction) a3dp_get_resfit, METH_NOARGS, "Gets the SPAresfit resolution" }, - { "get_resmch", (PyCFunction) a3dp_get_resmch, METH_NOARGS, "Gets the resmch resolution" }, - { "get_resnor", (PyCFunction) a3dp_get_resnor, METH_NOARGS, "Gets the SPAresnor resolution" }, - { "distance_to_point", (PyCFunction) a3dp_distance_to_point, METH_VARARGS | METH_KEYWORDS, "Determines the distance between two points" }, - { "distance_to_point_squared", (PyCFunction) a3dp_distance_to_point_squared, METH_VARARGS | METH_KEYWORDS, "\tComputes the squared distance between two positions" }, - { NULL, NULL, 0, NULL } + (char *) "n", + (char *) "freelisting", + NULL }; -struct PyModuleDef - a3dp_module = + // Try to parse input arguments and/or keywords + // api_start_modeller does not utilize the "n" argument, but following the implementation but make it optional + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist, &input_n, &input_freelisting)) + return NULL; + + // Disable ACIS freelisting facility if freelisting=False + if (!input_freelisting) { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; + // Display a warning message + PyErr_WarnEx(PyExc_Warning, "Disabling ACIS freelisting...", 0); + // Disable ACIS freelisting + base_configuration base_config; + base_config.enable_freelists = FALSE; + base_config.raw_allocator = malloc; + base_config.raw_destructor = free; + initialize_base(&base_config); + // Set the global variable for terminate_nase + disabled_acis_freelisting = true; + } -PyMODINIT_FUNC -PyInit_Modeler(void) + // Call ACIS API and check outcome + outcome result; + result = api_start_modeller(input_n); + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_stop_modeller(PyObject *self) { - PyObject *m; + // Call ACIS API and check outcome + outcome result; + result = api_stop_modeller(); - m = PyModule_Create(&a3dp_module); - if (m == NULL) + // If ACIS freelisting disabled, we need to call terminate_base() + if (disabled_acis_freelisting) + { + // Display a warning message + PyErr_WarnEx(PyExc_Warning, "Terminating ACIS...", 0); + terminate_base(); + } + + // Check outcome + if (!check_outcome(result)) return NULL; + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_is_modeler_started(PyObject *self) +{ + // Initialize variables + logical check_modeler; + + // Call ACIS API + check_modeler = is_modeler_started(); + + // Return Python value + if (check_modeler) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} - // SPAposition - if (PyType_Ready(&a3dp_type_SPAposition) < 0) +static PyObject * +ACIS_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + double input_value; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sd", kwlist, &input_name, &input_value)) return NULL; - Py_INCREF(&a3dp_type_SPAposition); - PyModule_AddObject(m, "SPAposition", (PyObject *) &a3dp_type_SPAposition); - // SPAtransf - if (PyType_Ready(&a3dp_type_SPAtransf) < 0) + API_BEGIN + + result = api_set_dbl_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_SPAtransf); - PyModule_AddObject(m, "SPAtransf", (PyObject *) &a3dp_type_SPAtransf); + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + int input_value; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; - // SPAmatrix - if (PyType_Ready(&a3dp_type_SPAmatrix) < 0) + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si", kwlist, &input_name, &input_value)) return NULL; - Py_INCREF(&a3dp_type_SPAmatrix); - PyModule_AddObject(m, "SPAmatrix", (PyObject *) &a3dp_type_SPAmatrix); - // SPAvector - if (PyType_Ready(&a3dp_type_SPAvector) < 0) + API_BEGIN + + result = api_set_int_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_SPAvector); - PyModule_AddObject(m, "SPAvector", (PyObject *) &a3dp_type_SPAvector); + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + const char *input_value = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; - // SPAunit_vector - if (PyType_Ready(&a3dp_type_SPAunitvector) < 0) + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &input_name, &input_value)) return NULL; - Py_INCREF(&a3dp_type_SPAunitvector); - PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &a3dp_type_SPAunitvector); - // SPApar_pos - if (PyType_Ready(&a3dp_type_SPAparpos) < 0) + API_BEGIN + + result = api_set_str_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_SPAparpos); - PyModule_AddObject(m, "SPApar_pos", (PyObject *) &a3dp_type_SPAparpos); + else + Py_RETURN_NONE; +} - // SPApar_vec - if (PyType_Ready(&a3dp_type_SPAparvec) < 0) +static PyObject * +ACIS_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL, *input_block = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + (char *) "block", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_pt1, &input_pt2, &input_block)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_SPAposition(input_pt1)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a SPAposition object"); + return NULL; + } + + if (!_ACIS_check_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAposition object"); + return NULL; + } + + if (!_ACIS_check_BODY(input_block)) + { + PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); return NULL; - Py_INCREF(&a3dp_type_SPAparvec); - PyModule_AddObject(m, "SPApar_vec", (PyObject *) &a3dp_type_SPAparvec); + } + + API_BEGIN + + // Convert PyObject to ACIS objects + SPAposition *_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; + SPAposition *_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; + BODY *&_block = (BODY *&) ((ACIS_Entity_BODY *) input_block)->base_obj._acis_obj; - if (PyType_Ready(&a3dp_type_FileInfo) < 0) + // Call ACIS API + result = api_solid_block(*_pt1, *_pt2, _block); + + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; + else + Py_RETURN_NONE; +} - Py_INCREF(&a3dp_type_FileInfo); - PyModule_AddObject(m, "FileInfo", (PyObject *) &a3dp_type_FileInfo); +static PyObject * +ACIS_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_x, input_y, input_z; + PyObject *input_body = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + (char *) "body", + NULL + }; - // Create a dictionary object for NDBOOL_KEEP enum - PyObject *_ndbk_dict; - _ndbk_dict = PyDict_New(); - if (_ndbk_dict != NULL) + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddO", kwlist, &input_x, &input_y, &input_z, &input_body)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_body)) { - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_NEITHER", PyLong_FromLong(0L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_TOOL", PyLong_FromLong(1L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BLANK", PyLong_FromLong(2L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BOTH", PyLong_FromLong(3L)); + PyErr_SetString(PyExc_TypeError, "The fourth argument must be a BODY object"); + return NULL; } - // NDBOOL_KEEP - a3dp_type_NDBOOLKEEP.tp_dict = _ndbk_dict; - if (PyType_Ready(&a3dp_type_NDBOOLKEEP) < 0) + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_body = (BODY *&) ((ACIS_Entity_BODY *) input_body)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_cuboid(input_x, input_y, input_z, _body); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2, input_top; + PyObject *input_frust = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "top", + (char *) "frust", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_frust)) return NULL; - Py_INCREF(&a3dp_type_NDBOOLKEEP); - PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &a3dp_type_NDBOOLKEEP); - // Create a dictionary object for sweep_bool_type enum - PyObject *_sbt_dict; - _sbt_dict = PyDict_New(); - if (_sbt_dict != NULL) + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_frust)) { - PyDict_SetItemString(_sbt_dict, "UNITE", PyLong_FromLong(0L)); - PyDict_SetItemString(_sbt_dict, "INTERSECT", PyLong_FromLong(1L)); - PyDict_SetItemString(_sbt_dict, "SUBTRACT", PyLong_FromLong(2L)); - PyDict_SetItemString(_sbt_dict, "LIMIT", PyLong_FromLong(3L)); - PyDict_SetItemString(_sbt_dict, "KEEP_BOTH", PyLong_FromLong(4L)); + PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); + return NULL; } - // sweep_bool_type - a3dp_type_sweepbooltype.tp_dict = _sbt_dict; - if (PyType_Ready(&a3dp_type_sweepbooltype) < 0) + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_frust = (BODY *&) ((ACIS_Entity_BODY *) input_frust)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_frustum(input_height, input_radius1, input_radius2, input_top, _frust); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2; + int input_nsides; + PyObject *input_prism = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "nsides", + (char *) "frust", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_nsides, &input_prism)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_prism)) + { + PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); return NULL; - Py_INCREF(&a3dp_type_sweepbooltype); - PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &a3dp_type_sweepbooltype); + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_prism = (BODY *&) ((ACIS_Entity_BODY *) input_prism)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_prism(input_height, input_radius1, input_radius2, input_nsides, _prism); - // sweep_options - if (PyType_Ready(&a3dp_type_sweep_options) < 0) + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_sweep_options); - PyModule_AddObject(m, "sweep_options", (PyObject *) &a3dp_type_sweep_options); + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2, input_top; + int input_nsides; + PyObject *input_pyramid = NULL; - // make_sweep_path_options - if (PyType_Ready(&a3dp_type_make_sweep_path_options) < 0) + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "top", + (char *) "nsides", + (char *) "pyramid", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_nsides, &input_pyramid)) return NULL; - Py_INCREF(&a3dp_type_make_sweep_path_options); - PyModule_AddObject(m, "make_sweep_path_options", (PyObject *) &a3dp_type_make_sweep_path_options); - // Add ENTITY to the module - if (PyType_Ready(&a3dp_type_ENTITY) < 0) + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_pyramid)) + { + PyErr_SetString(PyExc_TypeError, "The sixth argument must be a BODY object"); return NULL; - Py_INCREF(&a3dp_type_ENTITY); - PyModule_AddObject(m, "ENTITY", (PyObject *) &a3dp_type_ENTITY); + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_pyramid = (BODY *&) ((ACIS_Entity_BODY *) input_pyramid)->base_obj._acis_obj; - // Add BODY to the module - a3dp_type_BODY.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_BODY) < 0) + // Call ACIS API + result = api_make_pyramid(input_height, input_radius1, input_radius2, input_top, input_nsides, _pyramid); + + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_BODY); - PyModule_AddObject(m, "BODY", (PyObject *) &a3dp_type_BODY); + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_radius; + PyObject *input_sph = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "radius", + (char *) "sph", + NULL + }; - // Add FACE to the module - a3dp_type_FACE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_FACE) < 0) + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_radius, &input_sph)) return NULL; - Py_INCREF(&a3dp_type_FACE); - PyModule_AddObject(m, "FACE", (PyObject *) &a3dp_type_FACE); - // Add EDGE to the module - a3dp_type_EDGE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_EDGE) < 0) + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_sph)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a BODY object"); return NULL; - Py_INCREF(&a3dp_type_EDGE); - PyModule_AddObject(m, "EDGE", (PyObject *) &a3dp_type_EDGE); + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_sph = (BODY *&) ((ACIS_Entity_BODY *) input_sph)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_sphere(input_radius, _sph); + + API_END - // Add WIRE to the module - a3dp_type_WIRE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_WIRE) < 0) + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_WIRE); - PyModule_AddObject(m, "WIRE", (PyObject *) &a3dp_type_WIRE); + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_major_r, input_minor_r; + PyObject *input_tor = NULL; - // Add LUMP to the module - a3dp_type_LUMP.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_LUMP) < 0) + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "major_radius", + (char *) "minor_radius", + (char *) "tor", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_major_r, &input_minor_r, &input_tor)) return NULL; - Py_INCREF(&a3dp_type_LUMP); - PyModule_AddObject(m, "LUMP", (PyObject *) &a3dp_type_LUMP); - // Add SHELL to the module - a3dp_type_SHELL.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_SHELL) < 0) + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_tor)) + { + PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); return NULL; - Py_INCREF(&a3dp_type_SHELL); - PyModule_AddObject(m, "SHELL", (PyObject *) &a3dp_type_SHELL); + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tor = (BODY *&) ((ACIS_Entity_BODY *) input_tor)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_torus(input_major_r, input_minor_r, _tor); - // Add SUBSHELL to the module - a3dp_type_SUBSHELL.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_SUBSHELL) < 0) + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_SUBSHELL); - PyModule_AddObject(m, "SUBSHELL", (PyObject *) &a3dp_type_SUBSHELL); + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_entity = NULL, *input_trans = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "entity", + (char *) "trans", + NULL + }; - // Add COEDGE to the module - a3dp_type_COEDGE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_COEDGE) < 0) + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity, &input_trans)) return NULL; - Py_INCREF(&a3dp_type_COEDGE); - PyModule_AddObject(m, "COEDGE", (PyObject *) &a3dp_type_COEDGE); - // Add LOOP to the module - a3dp_type_LOOP.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_LOOP) < 0) + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_entity)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); return NULL; - Py_INCREF(&a3dp_type_LOOP); - PyModule_AddObject(m, "LOOP", (PyObject *) &a3dp_type_LOOP); + } - // Add VERTEX to the module - a3dp_type_VERTEX.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_VERTEX) < 0) + if (!_ACIS_check_SPAtransf(input_trans)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAtransf object"); return NULL; - Py_INCREF(&a3dp_type_VERTEX); - PyModule_AddObject(m, "VERTEX", (PyObject *) &a3dp_type_VERTEX); + } + + API_BEGIN + + // Convert PyObject to ACIS objects + ENTITY *&_entity = ((ACIS_Entity_BODY *) input_entity)->base_obj._acis_obj; + SPAtransf *&_trans = ((ACIS_GeometricAtoms_SPAtransf *) input_trans)->_acis_obj; + + // Call ACIS API + result = api_apply_transf(_entity, *_trans); - // Add SURFACE to the module - a3dp_type_SURFACE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_SURFACE) < 0) + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_SURFACE); - PyModule_AddObject(m, "SURFACE", (PyObject *) &a3dp_type_SURFACE); + else + Py_RETURN_NONE; +} - // Add CONE to the module - a3dp_type_CONE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_CONE) < 0) +static PyObject * +ACIS_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_entity = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "entity", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity)) return NULL; - Py_INCREF(&a3dp_type_CONE); - PyModule_AddObject(m, "CONE", (PyObject *) &a3dp_type_CONE); - // Add PLANE to the module - a3dp_type_PLANE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_PLANE) < 0) + // Type checks for ACIS objects + if (!_ACIS_check_BODY(input_entity)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); return NULL; - Py_INCREF(&a3dp_type_PLANE); - PyModule_AddObject(m, "PLANE", (PyObject *) &a3dp_type_PLANE); + } + + API_BEGIN - // Add SPHERE to the module - a3dp_type_SPHERE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_SPHERE) < 0) + // Convert PyObject to ACIS objects + ENTITY *&_entity = ((ACIS_Entity_BODY *) input_entity)->base_obj._acis_obj; + + // Call ACIS API + result = api_remove_transf(_entity); + + API_END + + // Check outcome + if (!check_outcome(result)) return NULL; - Py_INCREF(&a3dp_type_SPHERE); - PyModule_AddObject(m, "SPHERE", (PyObject *) &a3dp_type_SPHERE); + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_faces = NULL, *input_body = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "faces", + (char *) "body", + NULL + }; - // Add SPLINE to the module - a3dp_type_SPLINE.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_SPLINE) < 0) + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_faces, &input_body)) return NULL; - Py_INCREF(&a3dp_type_SPLINE); - PyModule_AddObject(m, "SPLINE", (PyObject *) &a3dp_type_SPLINE); - // Add TORUS to the module - a3dp_type_TORUS.tp_base = &a3dp_type_ENTITY; - if (PyType_Ready(&a3dp_type_TORUS) < 0) + // First argument must be a tuple of faces + PyObject *seq = PySequence_Fast(input_faces, "First argument must be a sequence of FACE objects"); + + // ACIS API has a limitation in api_sheet_from_ff function: As of version R2017, it can handle only 1 face + Py_ssize_t face_array_size = PySequence_Fast_GET_SIZE(seq); + if (face_array_size <= 0) + { + PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); + Py_DECREF(seq); return NULL; - Py_INCREF(&a3dp_type_TORUS); - PyModule_AddObject(m, "TORUS", (PyObject *) &a3dp_type_TORUS); + } + else if (face_array_size > 1) + { + PyErr_WarnEx(PyExc_Warning, "ACIS API does not support generation of sheet bodies from multiple faces.", 0); + } + + PyObject *faceobj = PySequence_Fast_GET_ITEM(seq, 0); + + API_BEGIN + + FACE *&_face = (FACE *&) ((ACIS_Entity_FACE *) faceobj)->base_obj._acis_obj; + + FACE *_faces[1]; + _faces[0] = _face; + + BODY *&_body = (BODY *&) ((ACIS_Entity_BODY *) input_body)->base_obj._acis_obj; + + result = api_sheet_from_ff(1, _faces, _body); + + API_END - // Add surface to the module - if (PyType_Ready(&a3dp_type_surface) < 0) + // PySequence_Fast generates a new reference + Py_DECREF(seq); + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error return NULL; - Py_INCREF(&a3dp_type_surface); - PyModule_AddObject(m, "surface", (PyObject *) &a3dp_type_surface); + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + + + +static PyMethodDef + module_methods[] = + { + { "api_start_modeller", (PyCFunction) ACIS_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Starts the 3D ACIS Modeler" }, + { "api_stop_modeller", (PyCFunction) ACIS_api_stop_modeller, METH_NOARGS, "Stops the 3D ACIS Modeler" }, + { "is_modeler_started", (PyCFunction) ACIS_is_modeler_started, METH_NOARGS, "Checks if the 3D ACIS Modeler started" }, + { "api_start_modeler", (PyCFunction) ACIS_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Alternative way to call api_start_modeller()" }, + { "api_stop_modeler", (PyCFunction) ACIS_api_stop_modeller, METH_NOARGS, "Alternative way to call api_stop_modeller()" }, + { "api_set_dbl_option", (PyCFunction) ACIS_api_set_dbl_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given double" }, + { "api_set_int_option", (PyCFunction) ACIS_api_set_int_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given integer" }, + { "api_set_str_option", (PyCFunction) ACIS_api_set_str_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given string" }, + { "api_solid_block", (PyCFunction) ACIS_api_solid_block, METH_VARARGS | METH_KEYWORDS, "Creates a solid block given two positions on a diagonal of the block" }, + { "api_make_cuboid", (PyCFunction) ACIS_api_make_cuboid, METH_VARARGS | METH_KEYWORDS, "Creates cuboid of given width (x), depth (y) and height (z)" }, + { "api_make_frustum", (PyCFunction) ACIS_api_make_frustum, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical cone or cylinder of given height and radii" }, + { "api_make_prism", (PyCFunction) ACIS_api_make_prism, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical prism of given height, radii, and number of sides" }, + { "api_make_pyramid", (PyCFunction) ACIS_api_make_pyramid, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical pyramid of given height, radii, and number of sides" }, + { "api_make_sphere", (PyCFunction) ACIS_api_make_sphere, METH_VARARGS | METH_KEYWORDS, "Creates a sphere of given radius, centered at the origin" }, + { "api_make_torus", (PyCFunction) ACIS_api_make_torus, METH_VARARGS | METH_KEYWORDS, "Creates a torus of given major and minor radii centered at the origin" }, + { "api_apply_transf", (PyCFunction) ACIS_api_apply_transf, METH_VARARGS | METH_KEYWORDS, "Changes the transform entity attached to a body" }, + { "api_remove_transf", (PyCFunction) ACIS_api_remove_transf, METH_VARARGS | METH_KEYWORDS, "Removes (discards) the transformation of a body" }, + { "api_sheet_from_ff", (PyCFunction) ACIS_api_sheet_from_ff, METH_VARARGS | METH_KEYWORDS, "Creates a sheet body as a copy of a face" }, + { NULL, NULL, 0, NULL } + }; + +// Module documentation can be accessible via __doc__ +const char *module_name = "Modeler"; +const char *module_documentation = "3D ACIS Modeler main modeling component"; - // Initialize ACIS ENTITY_LIST class as a Python type - if (PyType_Ready(&a3dp_type_ENTITYLIST) < 0) +static struct PyModuleDef + ACIS_Modeler_module = + { + PyModuleDef_HEAD_INIT, + module_name, // name of the module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + module_methods + }; + +PyMODINIT_FUNC +PyInit_Modeler(void) +{ + PyObject *m; + + m = PyModule_Create(&ACIS_Modeler_module); + if (m == NULL) return NULL; - Py_INCREF(&a3dp_type_ENTITYLIST); - PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &a3dp_type_ENTITYLIST); return m; } diff --git a/src/acis_modeler.h b/src/acis_modeler.h index a7028bf..c2b07aa 100644 --- a/src/acis_modeler.h +++ b/src/acis_modeler.h @@ -9,12 +9,19 @@ * */ -#ifndef A3DPY_MODELER_H -#define A3DPY_MODELER_H +#ifndef ACIS_MODELER_H +#define ACIS_MODELER_H #include -#include -#include "acis_api.h" +#include +#include +#include -#endif // !A3DPY_MODELER_H +#include "acis_entity.h" +#include "acis_geometric_atoms.h" +#include "acis_saverestore.h" +#include "acis_lists.h" +#include "utilities.h" + +#endif //!ACIS_MODELER_H diff --git a/src/acis_operators.cpp b/src/acis_operators.cpp deleted file mode 100644 index a6a4a87..0000000 --- a/src/acis_operators.cpp +++ /dev/null @@ -1,802 +0,0 @@ -#include "acis_operators.h" - - -PyObject * -a3dp_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_origin = NULL, *input_x_axis = NULL, *input_y_axis = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "new_origin", - (char *) "new_x_axis", - (char *) "new_y_axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_origin, &input_x_axis, &input_y_axis)) - return NULL; - - // Check inputs - if (!_PyCheck_SPAposition(input_origin)) - { - PyErr_SetString(PyExc_TypeError, "First parameter (new_origin) must be a SPAposition object"); - return NULL; - } - - if (!_PyCheck_SPAunit_vector(input_x_axis)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (new_x_axis) must be a SPAunit_vector object"); - return NULL; - } - - if (!_PyCheck_SPAunit_vector(input_y_axis)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (new_y_axis) must be a SPAunit_vector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAposition *&_new_origin = ((a3dp_SPAposition *) input_origin)->_acis_obj; - SPAunit_vector *&_new_x_axis = ((a3dp_SPAunit_vector *) input_x_axis)->_acis_obj; - SPAunit_vector *&_new_y_axis = ((a3dp_SPAunit_vector *) input_y_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = coordinate_transf(*_new_origin, *_new_x_axis, *_new_y_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_make_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_affine = NULL, *input_translation = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "affine", - (char *) "translation", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_affine, &input_translation)) - return NULL; - - // Check inputs - if (!_PyCheck_SPAmatrix(input_affine)) - { - PyErr_SetString(PyExc_TypeError, "First parameter (affine) must be a SPAmatrix object"); - return NULL; - } - - if (!_PyCheck_SPAvector(input_translation)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (translate) must be a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAmatrix *&_affine = ((a3dp_SPAmatrix *) input_affine)->_acis_obj; - SPAvector *&_translation = ((a3dp_SPAvector *) input_translation)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = make_transf(*_affine, *_translation); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_axis = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_axis)) - return NULL; - - // Check inputs - if (!_PyCheck_SPAvector(input_axis)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_axis = ((a3dp_SPAvector *) input_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = reflect_transf(*_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_axis = NULL; - double input_angle; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "angle", - (char *) "axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dO", kwlist, &input_angle, &input_axis)) - return NULL; - - // Check inputs - if (!_PyCheck_SPAvector(input_axis)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_axis = ((a3dp_SPAvector *) input_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = rotate_transf(input_angle, *_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL, *input_arg6 = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "scale", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOOO", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5, &input_arg6)) - return NULL; - - SPAtransf retval; - - if (!PyFloat_Check(input_arg1)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg1 = PyFloat_AsDouble(input_arg1); - - if (input_arg2 != NULL || input_arg3 != NULL) - { - if (!PyFloat_Check(input_arg2) && !PyFloat_Check(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg2 = PyFloat_AsDouble(input_arg2); - double _arg3 = PyFloat_AsDouble(input_arg3); - - if (input_arg4 != NULL || input_arg5 != NULL || input_arg6 != NULL) - { - if (!PyFloat_Check(input_arg4) && !PyFloat_Check(input_arg5) && !PyFloat_Check(input_arg5)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg4 = PyFloat_AsDouble(input_arg4); - double _arg5 = PyFloat_AsDouble(input_arg5); - double _arg6 = PyFloat_AsDouble(input_arg5); - - retval = scale_transf(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6); - } - else - { - retval = scale_transf(_arg1, _arg2, _arg3); - } - } - else - { - retval = scale_transf(_arg1); - } - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double _shear_xy, _shear_xz, _shear_yz; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "shearxy", - (char *) "shearxz", - (char *) "shearyz", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddd", kwlist, &_shear_xy, &_shear_xz, &_shear_yz)) - return NULL; - - // Execute ACIS function - SPAtransf retval = shear_transf(_shear_xy, _shear_xz, _shear_yz); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_disp = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "disp", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_disp)) - return NULL; - - // "disp" must be a SPAvector object - if (!_PyCheck_SPAvector(input_disp)) - { - PyErr_SetString(PyExc_TypeError, "Expecting SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_disp = ((a3dp_SPAvector *) input_disp)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = translate_transf(*_disp); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _PyNew_SPAtransf(); - *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -PyObject * -a3dp_angle_between(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL, *input_z = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "z", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist, &input_v1, &input_v2, &input_z)) - return NULL; - - // Set return value - double _retval; - - // SPAvector scenario - if (_PyCheck_SPAvector(input_v1)) - { - if (!_PyCheck_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; - - if (input_z != NULL) - { - if (!_PyCheck_SPAvector(input_z)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_z = ((a3dp_SPAunit_vector *) input_z)->_acis_obj; - - _retval = angle_between(*_v1, *_v2, *_z); - } - else - { - _retval = angle_between(*_v1, *_v2); - } - } - else if (_PyCheck_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_PyCheck_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_z != NULL) - { - if (!_PyCheck_SPAunit_vector(input_z)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_z = ((a3dp_SPAunit_vector *) input_z)->_acis_obj; - - _retval = angle_between(*_v1, *_v2, *_z); - } - else - { - _retval = angle_between(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return PyFloat object - return PyFloat_FromDouble(_retval); -} - -PyObject * -a3dp_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - double input_res = -1.0; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "res", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_PyCheck_SPAvector(input_v1)) - { - if (!_PyCheck_SPAvector(input_v2) || !_PyCheck_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = antiparallel(*_v1, *_v2, input_res); - } - else - { - _retval = antiparallel(*_v1, *_v2); - } - } - else if (_PyCheck_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_PyCheck_SPAunit_vector(input_v2) || !_PyCheck_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector or SPAvector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = antiparallel(*_v1, *_v2, input_res); - } - else - { - _retval = antiparallel(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -PyObject * -a3dp_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - int input_same_dir = 0; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "same_dir", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i", kwlist, &input_v1, &input_v2, &input_same_dir)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_PyCheck_SPAvector(input_v1)) - { - if (!_PyCheck_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; - - _retval = are_parallel(*_v1, *_v2, input_same_dir); - } - else if (_PyCheck_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_PyCheck_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; - - _retval = are_parallel(*_v1, *_v2, input_same_dir); - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -PyObject * -a3dp_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_v1, &input_v2)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_PyCheck_SPAvector(input_v1)) - { - if (!_PyCheck_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; - - _retval = are_perpendicular(*_v1, *_v2); - } - else if (_PyCheck_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_PyCheck_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; - - _retval = are_perpendicular(*_v1, *_v2); - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -PyObject * -a3dp_biparallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - double input_res = -1.0; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "res", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_PyCheck_SPAvector(input_v1)) - { - if (!_PyCheck_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = biparallel(*_v1, *_v2, input_res); - } - else - { - _retval = biparallel(*_v1, *_v2); - } - } - else if (_PyCheck_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_PyCheck_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = biparallel(*_v1, *_v2, input_res); - } - else - { - _retval = biparallel(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -PyObject * -a3dp_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_ang; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "ang", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) - return NULL; - - double _retval = degrees_to_radians(input_ang); - - // Return double - return PyFloat_FromDouble(_retval); -} - -PyObject * -a3dp_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_ang; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "ang", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) - return NULL; - - double _retval = radians_to_degrees(input_ang); - - // Return double - return PyFloat_FromDouble(_retval); -} - -PyObject * -a3dp_get_resabs(PyObject *self) -{ - return PyFloat_FromDouble(get_resabs()); -} - -PyObject * -a3dp_get_resfit(PyObject *self) -{ - return PyFloat_FromDouble(get_resfit()); -} - -PyObject * -a3dp_get_resmch(PyObject *self) -{ - return PyFloat_FromDouble(get_resmch()); -} - -PyObject * -a3dp_get_resnor(PyObject *self) -{ - return PyFloat_FromDouble(get_resnor()); -} - -PyObject * -a3dp_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) - return NULL; - - if (!_PyCheck_SPAposition(input_pt1) || !_PyCheck_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); - return NULL; - } - - SPAposition *&_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; - SPAposition *&_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; - - // Return double - return PyFloat_FromDouble(distance_to_point(*_pt1, *_pt2)); -} - -PyObject * -a3dp_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL; - - // List of keyword arguments that this function can take - char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) - return NULL; - - if (!_PyCheck_SPAposition(input_pt1) || !_PyCheck_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); - return NULL; - } - - SPAposition *&_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; - SPAposition *&_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; - - // Return double - return PyFloat_FromDouble(distance_to_point_squared(*_pt1, *_pt2)); -} diff --git a/src/acis_operators.h b/src/acis_operators.h deleted file mode 100644 index 52e2047..0000000 --- a/src/acis_operators.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef A3DPY_OPERATORS_H -#define A3DPY_OPERATORS_H - -#include -#include - -#include "acis_includes.h" -#include "acis_classes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -PyObject *a3dp_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_get_resnor(PyObject *self); -PyObject *a3dp_get_resmch(PyObject *self); -PyObject *a3dp_get_resfit(PyObject *self); -PyObject *a3dp_get_resabs(PyObject *self); -PyObject *a3dp_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_biparallel(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_angle_between(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_make_transf(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs); - -#ifdef __cplusplus -} -#endif - -#endif // !A3DPY_OPERATORS_H diff --git a/src/acis_query.cpp b/src/acis_query.cpp new file mode 100644 index 0000000..5a84d17 --- /dev/null +++ b/src/acis_query.cpp @@ -0,0 +1,181 @@ +#include "acis_query.h" + + +static PyObject * +ACIS_Query_method_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "entity", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_ent)) + return NULL; + + if (!_ACIS_check_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + // Get the ACIS object from the user input + ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = get_owner_transf(_ent); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _ACIS_new_SPAtransf(); + *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +static PyObject * +ACIS_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL, *input_ent_list = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "ent", + (char *) "face_list", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) + return NULL; + + if (!_ACIS_check_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + if (!_ACIS_check_ENTITY_LIST(input_ent_list)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + API_BEGIN + + // Get the ACIS objects from the user input + ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; + ENTITY_LIST *&_face_list = ((ACIS_Lists_ENTITY_LIST *) input_ent_list)->_acis_obj; + + // Call ACIS function + result = api_get_faces(_ent, *_face_list); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } + +} + +static PyObject * +ACIS_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL, *input_ent_list = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "ent", + (char *) "edge_list", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) + return NULL; + + if (!_ACIS_check_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + if (!_ACIS_check_ENTITY_LIST(input_ent_list)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + API_BEGIN + + // Get the ACIS objects from the user input + ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; + ENTITY_LIST *&_edge_list = ((ACIS_Lists_ENTITY_LIST *) input_ent_list)->_acis_obj; + + // Call ACIS function + result = api_get_edges(_ent, *_edge_list); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } + +} + +static PyMethodDef + module_methods[] = + { + { "get_owner_transf", (PyCFunction) ACIS_Query_method_get_owner_transf, METH_VARARGS | METH_KEYWORDS, "Gets a copy of the SPAtransf from the owner of an ENTITY" }, + { "api_get_faces", (PyCFunction) ACIS_api_get_faces, METH_VARARGS | METH_KEYWORDS, "Gets all faces related to an entity" }, + { "api_get_edges", (PyCFunction) ACIS_api_get_edges, METH_VARARGS | METH_KEYWORDS, "Gets all the edges related to an entity" }, + { NULL, NULL, 0, NULL } + }; + +// Module documentation can be accessible via __doc__ +const char *module_name = "Query"; +const char *module_documentation = "Contains 3D Modeler ACIS geometric and topological queries"; + +static struct PyModuleDef + ACIS_Query_module = + { + PyModuleDef_HEAD_INIT, + module_name, // name of the module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + module_methods + }; + +PyMODINIT_FUNC +PyInit_Query(void) +{ + PyObject *m; + + m = PyModule_Create(&ACIS_Query_module); + if (m == NULL) + return NULL; + + return m; +} diff --git a/src/acis_spa.h b/src/acis_query.h similarity index 53% rename from src/acis_spa.h rename to src/acis_query.h index 9764acd..e176d95 100644 --- a/src/acis_spa.h +++ b/src/acis_query.h @@ -9,21 +9,18 @@ * */ -#ifndef A3D_SPA_H -#define A3D_SPA_H +#ifndef ACIS_GEOMETRIC_OPERATORS_H +#define ACIS_GEOMETRIC_OPERATORS_H #include -#include "acis_includes.h" +#include -#ifdef __cplusplus -extern "C" { -#endif +#include "acis_entity.h" +#include "acis_geometric_atoms.h" +#include "acis_lists.h" +#include "utilities.h" -PyObject *a3dp_spa_unlock_products(PyObject *self, PyObject *arg); +#include "acis_query_export.h" -#ifdef __cplusplus -} -#endif - -#endif // !A3D_SPA_H +#endif // !ACIS_GEOMETRIC_OPERATORS_H diff --git a/src/acis_saverestore.cpp b/src/acis_saverestore.cpp new file mode 100644 index 0000000..6a3f1a9 --- /dev/null +++ b/src/acis_saverestore.cpp @@ -0,0 +1,506 @@ +#include "acis_saverestore.h" + + +/** + * Save & Restore - FileInfo wrapper + */ + +static void +ACIS_SaveRestore_dealloc_FileInfo(ACIS_SaveRestore_FileInfo *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object itself + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_SaveRestore_new_FileInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_SaveRestore_FileInfo *self; + + self = (ACIS_SaveRestore_FileInfo *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_SaveRestore_init_FileInfo(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + self->_acis_obj = ACIS_NEW FileInfo(); + return 0; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_acis_version(ACIS_SaveRestore_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->acis_version()); +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_date(ACIS_SaveRestore_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->date()); +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_file_version(ACIS_SaveRestore_FileInfo *self) +{ + return PyLong_FromLong((long) self->_acis_obj->file_version()); +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_product_id(ACIS_SaveRestore_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->product_id()); +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_reset(ACIS_SaveRestore_FileInfo *self) +{ + self->_acis_obj->reset(); + Py_RETURN_NONE; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_reset_vars(ACIS_SaveRestore_FileInfo *self) +{ + self->_acis_obj->reset_vars(); + Py_RETURN_NONE; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_restore(ACIS_SaveRestore_FileInfo *self) +{ + self->_acis_obj->restore(); + Py_RETURN_NONE; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_save(ACIS_SaveRestore_FileInfo *self) +{ + self->_acis_obj->save(); + Py_RETURN_NONE; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_set_masked(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + unsigned long input_field; + PyObject *input_file = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "field", + (char *) "file", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "lO", kwlist, &input_field, &input_file)) + return NULL; + + // Check if the user input is a FileInfo object + if (_ACIS_check_FileInfo(input_file)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + // Convert PyObject to ENTITY_LIST + FileInfo *_file = ((ACIS_SaveRestore_FileInfo *) input_file)->_acis_obj; + + // Execute ACIS function + self->_acis_obj->set_masked(input_field, *_file); + + // Return None + Py_RETURN_NONE; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_set_product_id(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + const char *input_id = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "id", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &input_id)) + return NULL; + + self->_acis_obj->set_product_id(input_id); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_set_units(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + double input_count; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "count", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_count)) + return NULL; + + self->_acis_obj->set_units(input_count); + + Py_RETURN_NONE; +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_tol_abs(ACIS_SaveRestore_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->tol_abs()); +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_tol_nor(ACIS_SaveRestore_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->tol_nor()); +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_units(ACIS_SaveRestore_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->units()); +} + +static PyObject * +ACIS_SaveRestore_method_FileInfo_valid(ACIS_SaveRestore_FileInfo *self) +{ + self->_acis_obj->valid(); + Py_RETURN_NONE; +} + +static PyMemberDef + ACIS_SaveRestore_members_FileInfo[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_SaveRestore_methods_FileInfo[] = + { + { "acis_version", (PyCFunction) ACIS_SaveRestore_method_FileInfo_acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, + { "date", (PyCFunction) ACIS_SaveRestore_method_FileInfo_date, METH_NOARGS, "Returns the date on the save file" }, + { "file_version", (PyCFunction) ACIS_SaveRestore_method_FileInfo_file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, + { "product_id", (PyCFunction) ACIS_SaveRestore_method_FileInfo_product_id, METH_NOARGS, "Returns the ID of the product" }, + { "reset", (PyCFunction) ACIS_SaveRestore_method_FileInfo_reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, + { "reset_vars", (PyCFunction) ACIS_SaveRestore_method_FileInfo_reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, + { "restore", (PyCFunction) ACIS_SaveRestore_method_FileInfo_restore, METH_NOARGS, "Restores the file information from a save file" }, + { "save", (PyCFunction) ACIS_SaveRestore_method_FileInfo_save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, + //{ "set_masked", (PyCFunction)ACIS_SaveRestore_method_FileInfo_set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, + { "set_product_id", (PyCFunction) ACIS_SaveRestore_method_FileInfo_set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, + { "set_units", (PyCFunction) ACIS_SaveRestore_method_FileInfo_set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, + { "tol_abs", (PyCFunction) ACIS_SaveRestore_method_FileInfo_tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, + { "tol_nor", (PyCFunction) ACIS_SaveRestore_method_FileInfo_tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, + { "units", (PyCFunction) ACIS_SaveRestore_method_FileInfo_units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, + { "valid", (PyCFunction) ACIS_SaveRestore_method_FileInfo_valid, METH_NOARGS, "Checks the values of the units and product id" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_SaveRestore_type_FileInfo = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FileInfo", /* tp_name */ + sizeof(ACIS_SaveRestore_FileInfo), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_SaveRestore_dealloc_FileInfo, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "FileInfo object contains additional required save file header information", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_SaveRestore_methods_FileInfo, /* tp_methods */ + ACIS_SaveRestore_members_FileInfo, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_SaveRestore_init_FileInfo, /* tp_init */ + 0, /* tp_alloc */ + ACIS_SaveRestore_new_FileInfo, /* tp_new */ + }; + + +/** + * Save & Restore Interface Functions + */ + +static PyObject * +ACIS_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs) +{ + // According to the documentation, Python 3 doesn't do good with FILE* objects, so we take "file name" as an input + const char *input_filename = NULL; + int input_savemode; + PyObject *input_entitylist = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "file_name", + (char *) "text_mode", + (char *) "entity_list_save", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO", kwlist, &input_filename, &input_savemode, &input_entitylist)) + return NULL; + + // Check if the input is an ENTITY_LIST + if (!_ACIS_check_ENTITY_LIST(input_entitylist)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + // Using the file name input as a string, create a file handle + FILE *_file_handle = fopen(input_filename, "w"); + + // Check if the file has been opened correctly + if (_file_handle == NULL) + { + PyErr_SetString(PyExc_IOError, "Cannot open file for writing!"); + return NULL; + } + + // Set file writing mode + logical _text_mode = (input_savemode == 0) ? FALSE : TRUE; + + API_NOP_BEGIN + + // Convert PyObject to ENTITY_LIST + ENTITY_LIST *_save_list = ((ACIS_Lists_ENTITY_LIST *) input_entitylist)->_acis_obj; + + + // Call ACIS API and check outcome + result = api_save_entity_list(_file_handle, _text_mode, *_save_list); + + API_NOP_END + + // Don't forget to close the file handle + fclose(_file_handle); + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_product_id = 0; + int input_units = 0; + PyObject *input_info = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "info", + (char *) "product_id", + (char *) "units", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii", kwlist, &input_info, &input_product_id, &input_units)) + return NULL; + + // Check if we have a FileInfo object + if (!_ACIS_check_FileInfo(input_info)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + // Set up the value of mask + bool _product_id = input_product_id != 0; + bool _units = input_units != 0; + + unsigned long _mask; + if (_product_id && !_units) + { + _mask = FileIdent; + } + else if (!_product_id && _units) + { + _mask = FileUnits; + } + else + { + _mask = FileUnits | FileIdent; + } + + API_BEGIN + + // Convert PyObject to FileInfo + FileInfo *_info = ((ACIS_SaveRestore_FileInfo *) input_info)->_acis_obj; + + result = api_set_file_info(_mask, *_info); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_info = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "info", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_info)) + return NULL; + + // Check if we have a FileInfo object + if (_ACIS_check_FileInfo(input_info)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to FileInfo + FileInfo *_info = ((ACIS_SaveRestore_FileInfo *) input_info)->_acis_obj; + + result = api_get_file_info(*_info); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +static PyObject * +ACIS_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_major_version, input_minor_version; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "major_version", + (char *) "minor_version", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_major_version, &input_minor_version)) + return NULL; + + API_BEGIN + + result = api_save_version(input_major_version, input_minor_version); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + + +static PyMethodDef + module_methods[] = + { + { "api_save_entity_list", (PyCFunction) ACIS_api_save_entity_list, METH_VARARGS | METH_KEYWORDS, "Writes entities to a file in text or binary format" }, + { "api_set_file_info", (PyCFunction) ACIS_api_set_file_info, METH_VARARGS | METH_KEYWORDS, "Sets required header info to be written to ACIS save files" }, + { "api_get_file_info", (PyCFunction) ACIS_api_get_file_info, METH_O | METH_KEYWORDS, "Gets header info from the last restored file" }, + { "api_save_version", (PyCFunction) ACIS_api_save_version, METH_VARARGS | METH_KEYWORDS, "Sets the save file format" }, + { NULL, NULL, 0, NULL } + }; + +// Module documentation can be accessible via __doc__ +const char *module_name = "SaveRestore"; +const char *module_documentation = "Contains 3D ACIS Modeler save & restore related classes and functions"; + +static PyModuleDef + ACIS_SaveRestore_module = + { + PyModuleDef_HEAD_INIT, + module_name, + module_documentation, + -1, + module_methods + }; + +PyMODINIT_FUNC +PyInit_SaveRestore(void) +{ + PyObject *m; + m = PyModule_Create(&ACIS_SaveRestore_module); + if (m == NULL) + return NULL; + + if (PyType_Ready(&ACIS_SaveRestore_type_FileInfo) < 0) + return NULL; + + Py_INCREF(&ACIS_SaveRestore_type_FileInfo); + PyModule_AddObject(m, "FileInfo", (PyObject *) &ACIS_SaveRestore_type_FileInfo); + + return m; +} + +bool _ACIS_check_FileInfo(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_SaveRestore_type_FileInfo; +} diff --git a/src/acis_saverestore.h b/src/acis_saverestore.h new file mode 100644 index 0000000..a7b4505 --- /dev/null +++ b/src/acis_saverestore.h @@ -0,0 +1,44 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef ACIS_SAVERESTORE_H +#define ACIS_SAVERESTORE_H + +#include +#include + +#include +#include + +#include "acis_lists.h" +#include "utilities.h" + +#include "acis_saverestore_export.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// Define FileInfo +typedef struct +{ + PyObject_HEAD + FileInfo *_acis_obj; +} ACIS_SaveRestore_FileInfo; + +bool ACIS_SAVERESTORE_EXPORT _ACIS_check_FileInfo(PyObject *ob); + +#ifdef __cplusplus +} +#endif + +#endif // !ACIS_SAVERESTORE_H diff --git a/src/acis_spa.cpp b/src/acis_spa.cpp deleted file mode 100644 index 5e867d3..0000000 --- a/src/acis_spa.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "acis_spa.h" - - -PyObject * -a3dp_spa_unlock_products(PyObject *self, PyObject *arg) -{ - // Check if the input is a string - if (!PyUnicode_Check(arg)) - { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } - - // Convert PyObject to C-style string - const char *unlock_str = PyUnicode_AsUTF8(arg); - - // Call ACIS Licensing API - spa_unlock_result out = spa_unlock_products(unlock_str); - - // If license is good, then return True. Otherwise, return the licensing error message - if (SPA_UNLOCK_PASS == out.get_state()) - Py_RETURN_TRUE; - else - return PyUnicode_FromString(out.get_message_text()); -} diff --git a/src/acis_sweeping.cpp b/src/acis_sweeping.cpp new file mode 100644 index 0000000..89f6e65 --- /dev/null +++ b/src/acis_sweeping.cpp @@ -0,0 +1,551 @@ +#include "acis_sweeping.h" + + +/** + * make_sweep_path_options class + */ + +static void +ACIS_Sweeping_dealloc_SweepPathOptions(ACIS_Sweeping_SweepPathOptions *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_Sweeping_new_SweepPathOptions(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_Sweeping_SweepPathOptions *self; + + self = (ACIS_Sweeping_SweepPathOptions *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_Sweeping_init_SweepPathOptions(ACIS_Sweeping_SweepPathOptions *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW make_sweep_path_options(); + + return 0; +} + +static PyMemberDef + ACIS_Sweeping_members_SweepPathOptions[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Sweeping_methods_SweepPathOptions[] = + { + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Sweeping_type_SweepPathOptions = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.make_sweep_path_options", /* tp_name */ + sizeof(ACIS_Sweeping_SweepPathOptions), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_Sweeping_dealloc_SweepPathOptions, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Sweeping_methods_SweepPathOptions, /* tp_methods */ + ACIS_Sweeping_members_SweepPathOptions, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Sweeping_init_SweepPathOptions, /* tp_init */ + 0, /* tp_alloc */ + ACIS_Sweeping_new_SweepPathOptions, /* tp_new */ + }; + + +/** + * sweep_bool_type enum + */ + +static PyTypeObject + ACIS_Sweeping_type_SweepBoolType = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_bool_type", /* tp_name */ + sizeof(ACIS_Sweeping_SweepBoolType), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "Sweep to body boolean operation type", /* tp_doc */ + }; + + +/** + * sweep_options class + */ + +static void +ACIS_Sweeping_dealloc_SweepOptions(ACIS_Sweeping_SweepOptions *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + Py_TYPE(self)->tp_free((PyObject *) self); +} + +static PyObject * +ACIS_Sweeping_new_SweepOptions(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + ACIS_Sweeping_SweepOptions *self; + + self = (ACIS_Sweeping_SweepOptions *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +static int +ACIS_Sweeping_init_SweepOptions(ACIS_Sweeping_SweepOptions *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW sweep_options(); + + return 0; +} + +static PyObject * +ACIS_Sweeping_method_SweepOptions_set_bool_type(ACIS_Sweeping_SweepOptions *self, PyObject *args, PyObject *kwargs) +{ + // Just a testing... + self->_acis_obj->set_bool_type(KEEP_BOTH); + + Py_RETURN_NONE; +} + +static PyGetSetDef + ACIS_Sweeping_getseters_SweepOptions[] = + { + { NULL } /* Sentinel */ + }; + +static PyMemberDef + ACIS_Sweeping_members_SweepOptions[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + ACIS_Sweeping_methods_SweepOptions[] = + { + { "set_bool_type", (PyCFunction) ACIS_Sweeping_method_SweepOptions_set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + ACIS_Sweeping_type_SweepOptions = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_options", /* tp_name */ + sizeof(ACIS_Sweeping_SweepOptions), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) ACIS_Sweeping_dealloc_SweepOptions, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ACIS_Sweeping_methods_SweepOptions, /* tp_methods */ + ACIS_Sweeping_members_SweepOptions, /* tp_members */ + ACIS_Sweeping_getseters_SweepOptions, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) ACIS_Sweeping_init_SweepOptions, /* tp_init */ + 0, /* tp_alloc */ + ACIS_Sweeping_new_SweepOptions, /* tp_new */ + }; + + +/** + * Sweeping API Interface Functions + */ + +static PyObject * +ACIS_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pts = NULL, *input_path = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "pts", + (char *) "path", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pts, &input_path)) + return NULL; + + // Type checks for ACIS objects + if (!_ACIS_check_EDGE(input_path)) + { + PyErr_SetString(PyExc_TypeError, "Second argument (path) must be an EDGE object"); + return NULL; + } + + // The first object must be a python sequence containing SPAposition objects + PyObject *seq = PySequence_Fast(input_pts, "First argument (pts) must be a sequence of SPAposition objects, such as a list or a tuple"); + + Py_ssize_t position_vector_size = PySequence_Fast_GET_SIZE(seq); + if (position_vector_size <= 0) + { + PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); + Py_DECREF(seq); + return NULL; + } + + // It seems unnecessary to implement a SPAposition container as python itself provides a handful of containers for every purpose + SPAposition_vector _pts; + + for (Py_ssize_t i = 0; i < position_vector_size; i++) + { + PyObject *pt_temp; + pt_temp = PySequence_Fast_GET_ITEM(seq, i); + if (!_ACIS_check_SPAposition(pt_temp)) + { + PyErr_SetString(PyExc_TypeError, "Sequence must contain SPAposition objects"); + Py_DECREF(seq); + return NULL; + } + _pts.push_back(*((ACIS_GeometricAtoms_SPAposition *) pt_temp)->_acis_obj); + } + + API_BEGIN + + EDGE *&_path = (EDGE *&) ((ACIS_Entity_EDGE *) input_path)->base_obj._acis_obj; + + // Don't use make_sweep_path_options for now + result = api_make_sweep_path(_pts, _path); + + API_END + + // PySequence_Fast returns a new reference + Py_DECREF(seq); + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Clear SPAposition container + _pts.clear(); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +static PyObject * +ACIS_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL; + + // List of keyword arguments that this function can take + static char *kwlist[] = + { + (char *) "arg1", + (char *) "arg2", + (char *) "arg3", + (char *) "arg4", + (char *) "arg5", + NULL + }; + + // Try to parse input arguments and/or keywords (hold sweep_options for now) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO|O", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5)) + return NULL; + + /* + * IMPORTANT NOTE: This function wraps all 4 api_sweep_with_options overloads in one single Python function. + * The reason is that Python doesn't allow overloading with same function names but different signatures. + */ + + // In all overloads, first argument is always an ENTITY object + if (!_ACIS_check_ENTITY(input_arg1)) + { + PyErr_SetString(PyExc_TypeError, "First argument must be an ENTITY object"); + return NULL; + } + + API_BEGIN + + ENTITY *&_ent = (ENTITY *&) ((ACIS_Entity_ENTITY *) input_arg1)->_acis_obj; + + // Check if we are using the sweep along the axis overload + if (input_arg5 != NULL) + { + if (!_ACIS_check_SPAposition(input_arg2)) + { + PyErr_SetString(PyExc_TypeError, "Second argument must be a SPAposition object"); + return NULL; + } + + if (!_ACIS_check_SPAvector(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Third argument must be a SPAvector object"); + return NULL; + } + + if (!_ACIS_check_SweepOptions(input_arg4)) + { + PyErr_SetString(PyExc_TypeError, "Fourth argument must be a sweep_options object"); + return NULL; + } + + if (!_ACIS_check_BODY(input_arg5)) + { + PyErr_SetString(PyExc_TypeError, "Fifth argument must be a BODY object"); + return NULL; + } + + SPAposition *&_root = (SPAposition *&) ((ACIS_GeometricAtoms_SPAposition *) input_arg2)->_acis_obj; + SPAvector *&_axis = (SPAvector *&) ((ACIS_GeometricAtoms_SPAvector *) input_arg3)->_acis_obj; + sweep_options *&_opts = (sweep_options *&) ((ACIS_Sweeping_SweepOptions *) input_arg4)->_acis_obj; + BODY *&_new_body = (BODY *&) ((ACIS_Entity_BODY *) input_arg5)->base_obj._acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, *_root, *_axis, _opts, _new_body); + + } + else + { + // We must be using the other overloads, then the 3rd argument must be a sweep_options object + if (!_ACIS_check_SweepOptions(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Third argument must be a sweep_options object"); + return NULL; + } + + sweep_options *&_opts = (sweep_options *&) ((ACIS_Sweeping_SweepOptions *) input_arg3)->_acis_obj; + + // and the 4th argument must be a BODY object + if (!_ACIS_check_BODY(input_arg4)) + { + PyErr_SetString(PyExc_TypeError, "Fourth argument must be a BODY object"); + return NULL; + } + + BODY *&_new_body = (BODY *&) ((ACIS_Entity_BODY *) input_arg4)->base_obj._acis_obj; + + // Check for sweeping along a given edge or a wire overload + if (_ACIS_check_ENTITY(input_arg2)) + { + ENTITY *&_path = (ENTITY *&) ((ACIS_Entity_ENTITY *) input_arg2)->_acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, _path, _opts, _new_body); + } + else if (PyFloat_Check(input_arg2)) + { + // We must be using sweeping along a specified distance overload + double _distance = PyFloat_AsDouble(input_arg2); + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, _distance, _opts, _new_body); + } + else if (_ACIS_check_SPAvector(input_arg2)) + { + // We must be using sweeping along a specified vector overload + SPAvector *&_vec = (SPAvector *&) ((ACIS_GeometricAtoms_SPAvector *) input_arg2)->_acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, *_vec, _opts, _new_body); + } + else + { + PyErr_SetString(PyExc_TypeError, "Second argument must be an ENTITY, float or SPAvector object"); + return NULL; + } + + } + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +static PyMethodDef + module_methods[] = + { + { "api_make_sweep_path", (PyCFunction) ACIS_api_make_sweep_path, METH_VARARGS | METH_KEYWORDS, "Constructs a path useful for creating a swept surface" }, + { "api_sweep_with_options", (PyCFunction) ACIS_api_sweep_with_options, METH_VARARGS | METH_KEYWORDS, "Sweeps the given profile along an edge, a distance, a vector or an axis" }, + { NULL, NULL, 0, NULL } + }; + +// Module documentation can be accessible via __doc__ +const char *module_name = "Sweeping"; +const char *module_documentation = "Contains 3D ACIS Modeler sweeping API related classes and functions"; + +static struct PyModuleDef + ACIS_Sweeping_module = + { + PyModuleDef_HEAD_INIT, + module_name, // name of the module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + module_methods + }; + +PyMODINIT_FUNC +PyInit_Sweeping(void) +{ + PyObject *m; + + m = PyModule_Create(&ACIS_Sweeping_module); + if (m == NULL) + return NULL; + + // Create a dictionary object for sweep_bool_type enum + PyObject *_sbt_dict; + _sbt_dict = PyDict_New(); + if (_sbt_dict != NULL) + { + PyDict_SetItemString(_sbt_dict, "UNITE", PyLong_FromLong(0L)); + PyDict_SetItemString(_sbt_dict, "INTERSECT", PyLong_FromLong(1L)); + PyDict_SetItemString(_sbt_dict, "SUBTRACT", PyLong_FromLong(2L)); + PyDict_SetItemString(_sbt_dict, "LIMIT", PyLong_FromLong(3L)); + PyDict_SetItemString(_sbt_dict, "KEEP_BOTH", PyLong_FromLong(4L)); + } + + // sweep_bool_type + ACIS_Sweeping_type_SweepBoolType.tp_dict = _sbt_dict; + if (PyType_Ready(&ACIS_Sweeping_type_SweepBoolType) < 0) + return NULL; + Py_INCREF(&ACIS_Sweeping_type_SweepBoolType); + PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &ACIS_Sweeping_type_SweepBoolType); + + // sweep_options + if (PyType_Ready(&ACIS_Sweeping_type_SweepOptions) < 0) + return NULL; + Py_INCREF(&ACIS_Sweeping_type_SweepOptions); + PyModule_AddObject(m, "sweep_options", (PyObject *) &ACIS_Sweeping_type_SweepOptions); + + // make_sweep_path_options + if (PyType_Ready(&ACIS_Sweeping_type_SweepPathOptions) < 0) + return NULL; + Py_INCREF(&ACIS_Sweeping_type_SweepPathOptions); + PyModule_AddObject(m, "make_sweep_path_options", (PyObject *) &ACIS_Sweeping_type_SweepPathOptions); + + return m; +} + +PyObject *_ACIS_new_SweepBoolType() +{ + return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepBoolType, NULL); +} + +bool _ACIS_check_SweepBoolType(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepBoolType; +} + +PyObject *_ACIS_new_SweepOptions() +{ + return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepOptions, NULL); +} + +bool _ACIS_check_SweepOptions(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepOptions; +} + +PyObject *_ACIS_new_SweepPathOptions() +{ + return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepPathOptions, NULL); +} + +bool _ACIS_check_SweepPathOptions(PyObject *ob) +{ + return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepPathOptions; +} diff --git a/src/acis_sweeping.h b/src/acis_sweeping.h new file mode 100644 index 0000000..0a5d9da --- /dev/null +++ b/src/acis_sweeping.h @@ -0,0 +1,69 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef ACIS_SWEEPING_H +#define ACIS_SWEEPING_H + +#include +#include + +#include +#include +#include +#include + +#include "acis_entity.h" +#include "acis_geometric_atoms.h" +#include "utilities.h" + +#include "acis_sweeping_export.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// Define sweep_bool_type enum +typedef struct { + PyObject_HEAD +} ACIS_Sweeping_SweepBoolType; + +PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepBoolType(); + +bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepBoolType(PyObject *ob); + +// Define sweep_options +typedef struct +{ + PyObject_HEAD + sweep_options *_acis_obj; +} ACIS_Sweeping_SweepOptions; + +PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepOptions(); + +bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepOptions(PyObject *ob); + +// Define make_sweep_path_options +typedef struct +{ + PyObject_HEAD + make_sweep_path_options *_acis_obj; +} ACIS_Sweeping_SweepPathOptions; + +PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepPathOptions(); + +bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepPathOptions(PyObject *ob); + +#ifdef __cplusplus +} +#endif + +#endif // !ACIS_SWEEPING_H diff --git a/src/utilities.h b/src/utilities.h index 8129a90..dec548b 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -9,21 +9,14 @@ * */ -#ifndef A3DPY_UTILITIES_H -#define A3DPY_UTILITIES_H +#ifndef ACIS_UTILITIES_H +#define ACIS_UTILITIES_H #include -#include "acis_includes.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include +#include bool check_outcome(outcome &_retval); -#ifdef __cplusplus -} -#endif - -#endif // !A3DPY_UTILITIES_H +#endif //ACIS_UTILITIES_H From 25a16893de0c85eb033c6e4b6b20a2858001265a Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Sun, 10 Dec 2017 01:07:52 -0600 Subject: [PATCH 7/9] Revert "Revert "Major reorganization"" This reverts commit 227b14923fafe27145f4794b7690cd99b5315d57. --- CMakeLists.txt | 367 +--- CONTRIBUTING.md | 4 +- examples/01_generate_solid_block.py | 18 +- examples/02_boolean_subtract.py | 24 +- examples/03_sweeping.py | 34 +- examples/04_face_counting.py | 18 +- src/acis_api.cpp | 1445 ++++++++++++++ src/acis_api.h | 65 + src/acis_booleans.cpp | 333 ---- src/acis_booleans.h | 36 - src/acis_classes.cpp | 1694 ++++++++++++++++ src/acis_classes.h | 841 ++++++++ src/acis_entity.cpp | 2028 ++++++------------- src/acis_entity.h | 1167 +++++++++-- src/acis_enums.cpp | 22 + src/acis_enums.h | 102 + src/acis_geometric_atoms.cpp | 2778 --------------------------- src/acis_geometric_atoms.h | 114 -- src/acis_includes.h | 36 + src/acis_licensing.cpp | 61 - src/acis_lists.cpp | 440 ----- src/acis_lists.h | 46 - src/acis_modeler.cpp | 850 +++----- src/acis_modeler.h | 17 +- src/acis_operators.cpp | 802 ++++++++ src/acis_operators.h | 50 + src/acis_query.cpp | 181 -- src/acis_saverestore.cpp | 506 ----- src/acis_saverestore.h | 44 - src/acis_spa.cpp | 25 + src/{acis_query.h => acis_spa.h} | 21 +- src/acis_sweeping.cpp | 551 ------ src/acis_sweeping.h | 69 - src/utilities.h | 17 +- 34 files changed, 7011 insertions(+), 7795 deletions(-) create mode 100644 src/acis_api.cpp create mode 100644 src/acis_api.h delete mode 100644 src/acis_booleans.cpp delete mode 100644 src/acis_booleans.h create mode 100644 src/acis_classes.cpp create mode 100644 src/acis_classes.h create mode 100644 src/acis_enums.cpp create mode 100644 src/acis_enums.h delete mode 100644 src/acis_geometric_atoms.cpp delete mode 100644 src/acis_geometric_atoms.h create mode 100644 src/acis_includes.h delete mode 100644 src/acis_licensing.cpp delete mode 100644 src/acis_lists.cpp delete mode 100644 src/acis_lists.h create mode 100644 src/acis_operators.cpp create mode 100644 src/acis_operators.h delete mode 100644 src/acis_query.cpp delete mode 100644 src/acis_saverestore.cpp delete mode 100644 src/acis_saverestore.h create mode 100644 src/acis_spa.cpp rename src/{acis_query.h => acis_spa.h} (53%) delete mode 100644 src/acis_sweeping.cpp delete mode 100644 src/acis_sweeping.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6510ba1..969c389 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8 ) -project( ACISPython3 CXX ) +project( ACIS-Python3 CXX ) # # Application Configuration @@ -109,360 +109,27 @@ else() message( FATAL_ERROR "A valid Python interpreter is required for finding Python's site-packages directory!" ) endif() - -# -# ACIS Python Module - Licensing -# - -# Set source files -set( ACIS_SOURCES_Licensing - src/acis_licensing.cpp - ) - -# Generate Python module -add_library( Licensing SHARED ${ACIS_SOURCES_Licensing} ) - -# Set link targets -target_link_libraries( Licensing ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) - -# Add the build location to the include directories -target_include_directories( Licensing PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Licensing PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Licensing PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Licensing PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Licensing PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Licensing PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Entity (ENTITY, BODY, FACE, etc.) -# - -# Set source files -set( ACIS_SOURCES_Entity - src/acis_entity.h - src/acis_entity.cpp - ${PROJECT_BINARY_DIR}/acis_entity_export.h - ) - -# Generate Python module -add_library( Entity SHARED ${ACIS_SOURCES_Entity} ) - -# Generate export header file -generate_export_header( Entity - BASE_NAME acis_entity - ) - -# Set link targets -target_link_libraries( Entity ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} GeometricAtoms ) - -# Add the build location to the include directories -target_include_directories( Entity PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Entity PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Entity PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Entity PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Entity PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Entity PROPERTIES PREFIX "" ) - - # -# ACIS Python Module - Geometric Atoms (SPAposition, SPApar_pos, etc.) -# - -# Set source files -set( ACIS_SOURCES_GeometricAtoms - src/acis_geometric_atoms.h - src/acis_geometric_atoms.cpp - ${PROJECT_BINARY_DIR}/acis_geometric_atoms_export.h - ) - -# Generate Python module -add_library( GeometricAtoms SHARED ${ACIS_SOURCES_GeometricAtoms} ) - -# Generate export header file -generate_export_header( GeometricAtoms - BASE_NAME acis_geometric_atoms - ) - -# Set link targets -target_link_libraries( GeometricAtoms ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) - -# Add the build location to the include directories -target_include_directories( GeometricAtoms PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET GeometricAtoms PROPERTY CXX_STANDARD 11 ) -set_property( TARGET GeometricAtoms PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( GeometricAtoms PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( GeometricAtoms PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( GeometricAtoms PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Save & Restore (FileInfo, etc.) -# - -# Set source files -set( ACIS_SOURCES_SaveRestore - src/acis_saverestore.h - src/acis_saverestore.cpp - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_saverestore_export.h - ) - -# Generate Python module -add_library( SaveRestore SHARED ${ACIS_SOURCES_SaveRestore} ) - -# Generate export header file -generate_export_header( SaveRestore - BASE_NAME acis_saverestore - ) - -# Set link targets -target_link_libraries( SaveRestore ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Lists ) - -# Add the build location to the include directories -target_include_directories( SaveRestore PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET SaveRestore PROPERTY CXX_STANDARD 11 ) -set_property( TARGET SaveRestore PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( SaveRestore PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( SaveRestore PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( SaveRestore PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Lists (ENTITY_LIST, etc.) -# - -# Set source files -set( ACIS_SOURCES_Lists - src/acis_lists.h - src/acis_lists.cpp - ${PROJECT_BINARY_DIR}/acis_lists_export.h - ) - -# Generate Python module -add_library( Lists SHARED ${ACIS_SOURCES_Lists} ) - -# Generate export header file -generate_export_header( Lists - BASE_NAME acis_lists - ) - -# Set link targets -target_link_libraries( Lists ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity ) - -# Add the build location to the include directories -target_include_directories( Lists PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Lists PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Lists PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Lists PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Lists PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Lists PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Sweeping API -# - -# Set source files -set( ACIS_SOURCES_Sweeping - src/acis_sweeping.cpp - src/acis_sweeping.h - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_sweeping_export.h - ) - -# Generate Python module -add_library( Sweeping SHARED ${ACIS_SOURCES_Sweeping} ) - -# Generate export header file -generate_export_header( Sweeping - BASE_NAME acis_sweeping - ) - -# Set link targets. Note that Modeler has dependencies towards most helper modules. -target_link_libraries( Sweeping ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity GeometricAtoms ) - -# Add the build location to the include directories -target_include_directories( Sweeping PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Sweeping PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Sweeping PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Sweeping PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Sweeping PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Sweeping PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Booleans API -# - -# Set source files -set( ACIS_SOURCES_Booleans - src/acis_booleans.h - src/acis_booleans.cpp - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_booleans_export.h - ) - -# Generate Python module -add_library( Booleans SHARED ${ACIS_SOURCES_Booleans} ) - -# Generate export header file -generate_export_header( Booleans - BASE_NAME acis_booleans - ) - -# Set link targets -target_link_libraries( Booleans ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity ) - -# Add the build location to the include directories -target_include_directories( Booleans PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Booleans PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Booleans PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Booleans PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Booleans PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Booleans PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Query API -# - -# Set source files -set( ACIS_SOURCES_Query - src/acis_query.cpp - src/acis_query.h - src/utilities.cpp - src/utilities.h - ${PROJECT_BINARY_DIR}/acis_query_export.h - ) - -# Generate Python module -add_library( Query SHARED ${ACIS_SOURCES_Query} ) - -# Generate export header file -generate_export_header( Query - BASE_NAME acis_query - ) - -# Set link targets. Note that Modeler has dependencies towards most helper modules. -target_link_libraries( Query ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity GeometricAtoms Lists ) - -# Add the build location to the include directories -target_include_directories( Query PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) - -# Set required C++ standard -set_property( TARGET Query PROPERTY CXX_STANDARD 11 ) -set_property( TARGET Query PROPERTY CXX_STANDARD_REQUIRED ON ) - -# Add suffix to debug builds -if( WIN32 ) - set_target_properties( Query PROPERTIES DEBUG_POSTFIX "_d" ) -endif() - -# On Windows, Python modules have .pyd filename extension -if( WIN32 AND NOT CYGWIN ) - set_target_properties( Query PROPERTIES SUFFIX ".pyd" ) -endif() - -# This is only needed for the python case where a modulename.so is generated -set_target_properties( Query PROPERTIES PREFIX "" ) - - -# -# ACIS Python Module - Modeler Core +# ACIS Python Module # # Set source files set( ACIS_SOURCES_Modeler + src/acis_includes.h src/acis_modeler.cpp src/acis_modeler.h + src/acis_api.cpp + src/acis_api.h + src/acis_classes.cpp + src/acis_classes.h + src/acis_entity.cpp + src/acis_entity.h + src/acis_enums.cpp + src/acis_enums.h + src/acis_operators.cpp + src/acis_operators.h + src/acis_spa.cpp + src/acis_spa.h src/utilities.cpp src/utilities.h ) @@ -471,7 +138,7 @@ set( ACIS_SOURCES_Modeler add_library( Modeler SHARED ${ACIS_SOURCES_Modeler} ) # Set link targets. Note that Modeler has dependencies towards most helper modules. -target_link_libraries( Modeler ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity Lists SaveRestore GeometricAtoms ) +target_link_libraries( Modeler ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} ) # Add the build location to the include directories target_include_directories( Modeler PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) @@ -500,7 +167,7 @@ set_target_properties( Modeler PROPERTIES PREFIX "" ) # Install Python modules to APP_INSTALL_DIR install( - TARGETS Modeler Licensing Entity Lists SaveRestore GeometricAtoms Sweeping Query Booleans + TARGETS Modeler DESTINATION ${APP_INSTALL_DIR}/${APP_MODULE_NAME} ) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b94548..cd23451 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,8 +28,8 @@ I would like to introduce some rules on contributing to this module. #### Naming conventions in the Python module * Python objects are defined as `ACIS_{ModuleName}_{ACISName}` and located in the header files -* Type functions are defined as `ACIS_{ModuleName}_{function_name}_{ACISName}`, e.g. _ACIS_GeometricAtoms_init_SPAposition_ -* Methods for types are defined as `ACIS_{ModuleName}_method_{ACISName}_{MethodName}`, e.g. _ACIS_Lists_method_ENTITY_LIST_add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side +* Type functions are defined as `ACIS_{ModuleName}_{function_name}_{ACISName}`, e.g. _a3dp_init_SPAposition_ +* Methods for types are defined as `ACIS_{ModuleName}_method_{ACISName}_{MethodName}`, e.g. _a3dp_method_ENTITY_LIST_add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side * Module variables are defined as `ACIS_{ModuleName}_{function_name}`, e.g. _ACIS_Topology_module_ * Module init functions are defined as `PyInit_{ModuleName}` * ACIS API calls are defined as `ACIS_{API Call}`, e.g. _ACIS_api_start_modeller_ which corresponds to _api_start_modeller()_ on the C++ side diff --git a/examples/01_generate_solid_block.py b/examples/01_generate_solid_block.py index a4d2b3f..f8ab8b7 100644 --- a/examples/01_generate_solid_block.py +++ b/examples/01_generate_solid_block.py @@ -8,19 +8,19 @@ """ from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Generate a simple solid block -pt1 = GeometricAtoms.SPAposition(0.0, 0.0, 0.0) -pt2 = GeometricAtoms.SPAposition(50.0, 50.0, 25.0) -block = Entity.BODY() +pt1 = Modeler.SPAposition(0.0, 0.0, 0.0) +pt2 = Modeler.SPAposition(50.0, 50.0, 25.0) +block = Modeler.BODY() Modeler.api_solid_block(pt1, pt2, block) @@ -29,24 +29,24 @@ block.id = 1 # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() save_list.add(block) # Set file name filename = "ACIS_Ex01.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/02_boolean_subtract.py b/examples/02_boolean_subtract.py index c1fa636..fec05bc 100644 --- a/examples/02_boolean_subtract.py +++ b/examples/02_boolean_subtract.py @@ -10,31 +10,31 @@ # This example is taken from the book "Rapid Prototyping and Engineering Applications" by Frank W. Liou (Example 5.1) from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Booleans +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Make a cuboid -block = Entity.BODY() +block = Modeler.BODY() Modeler.api_make_cuboid(150, 75, 25, block) # Generate and apply transformation to the cuboid -block_vector = GeometricAtoms.SPAvector(0.0, 0.0, 12.7) -block_transf = GeometricAtoms.translate_transf(block_vector) +block_vector = Modeler.SPAvector(0.0, 0.0, 12.7) +block_transf = Modeler.translate_transf(block_vector) Modeler.api_apply_transf(block, block_transf) # Make a frustum -cylinder = Entity.BODY() +cylinder = Modeler.BODY() Modeler.api_make_frustum(19.05, 12.7, 12.7, 12.7, cylinder) # Generate and apply transformation to the frustum -cylinder_vector = GeometricAtoms.SPAvector(0.0, 0.0, 6.35) -cylinder_transf = GeometricAtoms.translate_transf(cylinder_vector) +cylinder_vector = Modeler.SPAvector(0.0, 0.0, 6.35) +cylinder_transf = Modeler.translate_transf(cylinder_vector) Modeler.api_apply_transf(cylinder, cylinder_transf) # Subtract frustum from cuboid @@ -45,24 +45,24 @@ block.id = 1 # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() save_list.add(block) # Set file name filename = "ACIS_Ex02.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/03_sweeping.py b/examples/03_sweeping.py index 3664f14..c90b04e 100644 --- a/examples/03_sweeping.py +++ b/examples/03_sweeping.py @@ -8,47 +8,47 @@ """ from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Sweeping, Query +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Make a cuboid -block = Entity.BODY() +block = Modeler.BODY() Modeler.api_make_cuboid(150, 75, 25, block) # Get faces of the cuboid -face_list = Lists.ENTITY_LIST() -Query.api_get_faces(block, face_list) +face_list = Modeler.ENTITY_LIST() +Modeler.api_get_faces(block, face_list) # Choose any face from the cuboid's face list block_face = face_list.first() # Convert the chosen face into a sheet body -sheet_body = Entity.BODY() +sheet_body = Modeler.BODY() Modeler.api_sheet_from_ff([block_face], sheet_body) # Make a sweep path -pt1 = GeometricAtoms.SPAposition(0.0, 0.0, 0.0) -pt2 = GeometricAtoms.SPAposition(10.0, 55.0, 23.0) -sweep_path = Entity.EDGE() -Sweeping.api_make_sweep_path([pt1, pt2], sweep_path) +pt1 = Modeler.SPAposition(0.0, 0.0, 0.0) +pt2 = Modeler.SPAposition(10.0, 55.0, 23.0) +sweep_path = Modeler.EDGE() +Modeler.api_make_sweep_path([pt1, pt2], sweep_path) # Sweep the chosen face using the sweep path -opts = Sweeping.sweep_options() -swept_body = Entity.BODY() -Sweeping.api_sweep_with_options(sheet_body, sweep_path, opts, swept_body) +opts = Modeler.sweep_options() +swept_body = Modeler.BODY() +Modeler.api_sweep_with_options(sheet_body, sweep_path, opts, swept_body) # Assign attributes after generation sheet_body.name = "Swept FACE" sheet_body.id = 1 # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() # api_sweep_with_options will modify sheet_body object as defined in its documentation save_list.add(sheet_body) @@ -56,14 +56,14 @@ filename = "ACIS_Ex03.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/examples/04_face_counting.py b/examples/04_face_counting.py index 8f4dec6..2a8cbec 100644 --- a/examples/04_face_counting.py +++ b/examples/04_face_counting.py @@ -8,17 +8,17 @@ """ from ACIS import utilities as utils -from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Query +from ACIS import Modeler # Start ACIS Modeler Modeler.api_start_modeller(0) # Unlock ACIS Modeler components unlock_key = utils.read_spa_license_key("license.txt") -Licensing.spa_unlock_products(unlock_key) +Modeler.spa_unlock_products(unlock_key) # Generate a truncated cone -frustum = Entity.BODY() +frustum = Modeler.BODY() Modeler.api_make_frustum(50, 20, 30, 10, frustum) # Assign attributes after generation @@ -26,32 +26,32 @@ frustum.id = 1 # Loop through the face list and print out the name of the entity type -face_list = Lists.ENTITY_LIST() -Query.api_get_faces(frustum, face_list) +face_list = Modeler.ENTITY_LIST() +Modeler.api_get_faces(frustum, face_list) for f in face_list.array(): fs = f.geometry() print(fs.type_name()) # Prepare for saving -save_list = Lists.ENTITY_LIST() +save_list = Modeler.ENTITY_LIST() save_list.add(frustum) # Set file name filename = "ACIS_Ex04.SAT" # ACIS requires FileInfo object to be set before saving SAT files -file_info = SaveRestore.FileInfo() +file_info = Modeler.FileInfo() file_info.set_product_id(filename) file_info.set_units(1.0) # milimeters -SaveRestore.api_set_file_info(file_info, product_id=True, units=True) +Modeler.api_set_file_info(file_info, product_id=True, units=True) ## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step) #Modeler.api_set_int_option("sequence_save_files", 1) # Save the model as a SAT file -SaveRestore.api_save_entity_list(filename, True, save_list) +Modeler.api_save_entity_list(filename, True, save_list) # Stop ACIS Modeler Modeler.api_stop_modeller() diff --git a/src/acis_api.cpp b/src/acis_api.cpp new file mode 100644 index 0000000..44442ce --- /dev/null +++ b/src/acis_api.cpp @@ -0,0 +1,1445 @@ +#include "acis_api.h" + + +bool disabled_acis_freelisting = false; + +PyObject * +a3dp_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_n = 0; + int input_freelisting = 1; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "n", + (char *) "freelisting", + NULL + }; + + // Try to parse input arguments and/or keywords + // api_start_modeller does not utilize the "n" argument, but following the implementation but make it optional + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist, &input_n, &input_freelisting)) + return NULL; + + // Disable ACIS freelisting facility if freelisting=False + if (!input_freelisting) + { + // Display a warning message + PyErr_WarnEx(PyExc_Warning, "Disabling ACIS freelisting...", 0); + // Disable ACIS freelisting + base_configuration base_config; + base_config.enable_freelists = FALSE; + base_config.raw_allocator = malloc; + base_config.raw_destructor = free; + initialize_base(&base_config); + // Set the global variable for terminate_nase + disabled_acis_freelisting = true; + } + + // Call ACIS API and check outcome + outcome result; + result = api_start_modeller(input_n); + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_stop_modeller(PyObject *self) +{ + // Call ACIS API and check outcome + outcome result; + result = api_stop_modeller(); + + // If ACIS freelisting disabled, we need to call terminate_base() + if (disabled_acis_freelisting) + { + // Display a warning message + PyErr_WarnEx(PyExc_Warning, "Terminating ACIS...", 0); + terminate_base(); + } + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_is_modeler_started(PyObject *self) +{ + // Initialize variables + logical check_modeler; + + // Call ACIS API + check_modeler = is_modeler_started(); + + // Return Python value + if (check_modeler) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + double input_value; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sd", kwlist, &input_name, &input_value)) + return NULL; + + API_BEGIN + + result = api_set_dbl_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + int input_value; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si", kwlist, &input_name, &input_value)) + return NULL; + + API_BEGIN + + result = api_set_int_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *input_name = NULL; + const char *input_value = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "name", + (char *) "value", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &input_name, &input_value)) + return NULL; + + API_BEGIN + + result = api_set_str_option(input_name, input_value); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL, *input_block = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + (char *) "block", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_pt1, &input_pt2, &input_block)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_SPAposition(input_pt1)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_BODY(input_block)) + { + PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + SPAposition *_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; + SPAposition *_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; + BODY *&_block = (BODY *&) ((a3dp_BODY *) input_block)->base_obj._acis_obj; + + // Call ACIS API + result = api_solid_block(*_pt1, *_pt2, _block); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_x, input_y, input_z; + PyObject *input_body = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + (char *) "body", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddO", kwlist, &input_x, &input_y, &input_z, &input_body)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_body)) + { + PyErr_SetString(PyExc_TypeError, "The fourth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_body = (BODY *&) ((a3dp_BODY *) input_body)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_cuboid(input_x, input_y, input_z, _body); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2, input_top; + PyObject *input_frust = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "top", + (char *) "frust", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_frust)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_frust)) + { + PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_frust = (BODY *&) ((a3dp_BODY *) input_frust)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_frustum(input_height, input_radius1, input_radius2, input_top, _frust); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2; + int input_nsides; + PyObject *input_prism = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "nsides", + (char *) "frust", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_nsides, &input_prism)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_prism)) + { + PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_prism = (BODY *&) ((a3dp_BODY *) input_prism)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_prism(input_height, input_radius1, input_radius2, input_nsides, _prism); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_height, input_radius1, input_radius2, input_top; + int input_nsides; + PyObject *input_pyramid = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "height", + (char *) "radius1", + (char *) "radius2", + (char *) "top", + (char *) "nsides", + (char *) "pyramid", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_nsides, &input_pyramid)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_pyramid)) + { + PyErr_SetString(PyExc_TypeError, "The sixth argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_pyramid = (BODY *&) ((a3dp_BODY *) input_pyramid)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_pyramid(input_height, input_radius1, input_radius2, input_top, input_nsides, _pyramid); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_radius; + PyObject *input_sph = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "radius", + (char *) "sph", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_radius, &input_sph)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_sph)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_sph = (BODY *&) ((a3dp_BODY *) input_sph)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_sphere(input_radius, _sph); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_major_r, input_minor_r; + PyObject *input_tor = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "major_radius", + (char *) "minor_radius", + (char *) "tor", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_major_r, &input_minor_r, &input_tor)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tor)) + { + PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tor = (BODY *&) ((a3dp_BODY *) input_tor)->base_obj._acis_obj; + + // Call ACIS API + result = api_make_torus(input_major_r, input_minor_r, _tor); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_entity = NULL, *input_trans = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "entity", + (char *) "trans", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity, &input_trans)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_entity)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + return NULL; + } + + if (!_PyCheck_SPAtransf(input_trans)) + { + PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAtransf object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + ENTITY *&_entity = ((a3dp_BODY *) input_entity)->base_obj._acis_obj; + SPAtransf *&_trans = ((a3dp_SPAtransf *) input_trans)->_acis_obj; + + // Call ACIS API + result = api_apply_transf(_entity, *_trans); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_entity = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "entity", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_entity)) + { + PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + ENTITY *&_entity = ((a3dp_BODY *) input_entity)->base_obj._acis_obj; + + // Call ACIS API + result = api_remove_transf(_entity); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_faces = NULL, *input_body = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "faces", + (char *) "body", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_faces, &input_body)) + return NULL; + + // First argument must be a tuple of faces + PyObject *seq = PySequence_Fast(input_faces, "First argument must be a sequence of FACE objects"); + + // ACIS API has a limitation in api_sheet_from_ff function: As of version R2017, it can handle only 1 face + Py_ssize_t face_array_size = PySequence_Fast_GET_SIZE(seq); + if (face_array_size <= 0) + { + PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); + Py_DECREF(seq); + return NULL; + } + else if (face_array_size > 1) + { + PyErr_WarnEx(PyExc_Warning, "ACIS API does not support generation of sheet bodies from multiple faces.", 0); + } + + PyObject *faceobj = PySequence_Fast_GET_ITEM(seq, 0); + + API_BEGIN + + FACE *&_face = (FACE *&) ((a3dp_FACE *) faceobj)->base_obj._acis_obj; + + FACE *_faces[1]; + _faces[0] = _face; + + BODY *&_body = (BODY *&) ((a3dp_BODY *) input_body)->base_obj._acis_obj; + + result = api_sheet_from_ff(1, _faces, _body); + + API_END + + // PySequence_Fast generates a new reference + Py_DECREF(seq); + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +/** + * Booleans API Interface Functions + */ + +PyObject * +a3dp_api_unite(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_unite(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_intersect(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_subtract(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_tool = NULL, *input_blank = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "tool", + (char *) "blank", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_BODY(input_tool)) + { + PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); + return NULL; + } + + if (!_PyCheck_BODY(input_blank)) + { + PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to ACIS objects + BODY *&_tool = (BODY *&) ((a3dp_BODY *) input_tool)->base_obj._acis_obj; + BODY *&_blank = (BODY *&) ((a3dp_BODY *) input_blank)->base_obj._acis_obj; + + // Call ACIS API + result = api_imprint(_tool, _blank); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too + _a3dp_make_null(input_tool); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs) +{ + /* TO-DO: Implement api_boolean_chop_body */ + return NULL; +} + +PyObject * +a3dp_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs) +{ + // According to the documentation, Python 3 doesn't do good with FILE* objects, so we take "file name" as an input + const char *input_filename = NULL; + int input_savemode; + PyObject *input_entitylist = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "file_name", + (char *) "text_mode", + (char *) "entity_list_save", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO", kwlist, &input_filename, &input_savemode, &input_entitylist)) + return NULL; + + // Check if the input is an ENTITY_LIST + if (!_PyCheck_ENTITY_LIST(input_entitylist)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + // Using the file name input as a string, create a file handle + FILE *_file_handle = fopen(input_filename, "w"); + + // Check if the file has been opened correctly + if (_file_handle == NULL) + { + PyErr_SetString(PyExc_IOError, "Cannot open file for writing!"); + return NULL; + } + + // Set file writing mode + logical _text_mode = (input_savemode == 0) ? FALSE : TRUE; + + API_NOP_BEGIN + + // Convert PyObject to ENTITY_LIST + ENTITY_LIST *_save_list = ((a3dp_ENTITY_LIST *) input_entitylist)->_acis_obj; + + + // Call ACIS API and check outcome + result = api_save_entity_list(_file_handle, _text_mode, *_save_list); + + API_NOP_END + + // Don't forget to close the file handle + fclose(_file_handle); + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_product_id = 0; + int input_units = 0; + PyObject *input_info = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "info", + (char *) "product_id", + (char *) "units", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii", kwlist, &input_info, &input_product_id, &input_units)) + return NULL; + + // Check if we have a FileInfo object + if (!_PyCheck_FileInfo(input_info)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + // Set up the value of mask + bool _product_id = input_product_id != 0; + bool _units = input_units != 0; + + unsigned long _mask; + if (_product_id && !_units) + { + _mask = FileIdent; + } + else if (!_product_id && _units) + { + _mask = FileUnits; + } + else + { + _mask = FileUnits | FileIdent; + } + + API_BEGIN + + // Convert PyObject to FileInfo + FileInfo *_info = ((a3dp_FileInfo *) input_info)->_acis_obj; + + result = api_set_file_info(_mask, *_info); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_info = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "info", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_info)) + return NULL; + + // Check if we have a FileInfo object + if (_PyCheck_FileInfo(input_info)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + API_BEGIN + + // Convert PyObject to FileInfo + FileInfo *_info = ((a3dp_FileInfo *) input_info)->_acis_obj; + + result = api_get_file_info(*_info); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +PyObject * +a3dp_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int input_major_version, input_minor_version; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "major_version", + (char *) "minor_version", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_major_version, &input_minor_version)) + return NULL; + + API_BEGIN + + result = api_save_version(input_major_version, input_minor_version); + + API_END + + // Check outcome + if (!check_outcome(result)) + return NULL; + else + Py_RETURN_NONE; +} + +/** + * Sweeping API Interface Functions + */ + +PyObject * +a3dp_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pts = NULL, *input_path = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pts", + (char *) "path", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pts, &input_path)) + return NULL; + + // Type checks for ACIS objects + if (!_PyCheck_EDGE(input_path)) + { + PyErr_SetString(PyExc_TypeError, "Second argument (path) must be an EDGE object"); + return NULL; + } + + // The first object must be a python sequence containing SPAposition objects + PyObject *seq = PySequence_Fast(input_pts, "First argument (pts) must be a sequence of SPAposition objects, such as a list or a tuple"); + + Py_ssize_t position_vector_size = PySequence_Fast_GET_SIZE(seq); + if (position_vector_size <= 0) + { + PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); + Py_DECREF(seq); + return NULL; + } + + // It seems unnecessary to implement a SPAposition container as python itself provides a handful of containers for every purpose + SPAposition_vector _pts; + + for (Py_ssize_t i = 0; i < position_vector_size; i++) + { + PyObject *pt_temp; + pt_temp = PySequence_Fast_GET_ITEM(seq, i); + if (!_PyCheck_SPAposition(pt_temp)) + { + PyErr_SetString(PyExc_TypeError, "Sequence must contain SPAposition objects"); + Py_DECREF(seq); + return NULL; + } + _pts.push_back(*((a3dp_SPAposition *) pt_temp)->_acis_obj); + } + + API_BEGIN + + EDGE *&_path = (EDGE *&) ((a3dp_EDGE *) input_path)->base_obj._acis_obj; + + // Don't use make_sweep_path_options for now + result = api_make_sweep_path(_pts, _path); + + API_END + + // PySequence_Fast returns a new reference + Py_DECREF(seq); + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Clear SPAposition container + _pts.clear(); + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "arg1", + (char *) "arg2", + (char *) "arg3", + (char *) "arg4", + (char *) "arg5", + NULL + }; + + // Try to parse input arguments and/or keywords (hold sweep_options for now) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO|O", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5)) + return NULL; + + /* + * IMPORTANT NOTE: This function wraps all 4 api_sweep_with_options overloads in one single Python function. + * The reason is that Python doesn't allow overloading with same function names but different signatures. + */ + + // In all overloads, first argument is always an ENTITY object + if (!_PyCheck_ENTITY(input_arg1)) + { + PyErr_SetString(PyExc_TypeError, "First argument must be an ENTITY object"); + return NULL; + } + + API_BEGIN + + ENTITY *&_ent = (ENTITY *&) ((a3dp_ENTITY *) input_arg1)->_acis_obj; + + // Check if we are using the sweep along the axis overload + if (input_arg5 != NULL) + { + if (!_PyCheck_SPAposition(input_arg2)) + { + PyErr_SetString(PyExc_TypeError, "Second argument must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_SPAvector(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Third argument must be a SPAvector object"); + return NULL; + } + + if (!_PyCheck_sweep_options(input_arg4)) + { + PyErr_SetString(PyExc_TypeError, "Fourth argument must be a sweep_options object"); + return NULL; + } + + if (!_PyCheck_BODY(input_arg5)) + { + PyErr_SetString(PyExc_TypeError, "Fifth argument must be a BODY object"); + return NULL; + } + + SPAposition *&_root = (SPAposition *&) ((a3dp_SPAposition *) input_arg2)->_acis_obj; + SPAvector *&_axis = (SPAvector *&) ((a3dp_SPAvector *) input_arg3)->_acis_obj; + sweep_options *&_opts = (sweep_options *&) ((a3dp_sweep_options *) input_arg4)->_acis_obj; + BODY *&_new_body = (BODY *&) ((a3dp_BODY *) input_arg5)->base_obj._acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, *_root, *_axis, _opts, _new_body); + + } + else + { + // We must be using the other overloads, then the 3rd argument must be a sweep_options object + if (!_PyCheck_sweep_options(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Third argument must be a sweep_options object"); + return NULL; + } + + sweep_options *&_opts = (sweep_options *&) ((a3dp_sweep_options *) input_arg3)->_acis_obj; + + // and the 4th argument must be a BODY object + if (!_PyCheck_BODY(input_arg4)) + { + PyErr_SetString(PyExc_TypeError, "Fourth argument must be a BODY object"); + return NULL; + } + + BODY *&_new_body = (BODY *&) ((a3dp_BODY *) input_arg4)->base_obj._acis_obj; + + // Check for sweeping along a given edge or a wire overload + if (_PyCheck_ENTITY(input_arg2)) + { + ENTITY *&_path = (ENTITY *&) ((a3dp_ENTITY *) input_arg2)->_acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, _path, _opts, _new_body); + } + else if (PyFloat_Check(input_arg2)) + { + // We must be using sweeping along a specified distance overload + double _distance = PyFloat_AsDouble(input_arg2); + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, _distance, _opts, _new_body); + } + else if (_PyCheck_SPAvector(input_arg2)) + { + // We must be using sweeping along a specified vector overload + SPAvector *&_vec = (SPAvector *&) ((a3dp_SPAvector *) input_arg2)->_acis_obj; + + // Call ACIS Sweeping API + result = api_sweep_with_options(_ent, *_vec, _opts, _new_body); + } + else + { + PyErr_SetString(PyExc_TypeError, "Second argument must be an ENTITY, float or SPAvector object"); + return NULL; + } + + } + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } +} + +PyObject * +a3dp_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "entity", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_ent)) + return NULL; + + if (!_PyCheck_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + // Get the ACIS object from the user input + ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = get_owner_transf(_ent); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL, *input_ent_list = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ent", + (char *) "face_list", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) + return NULL; + + if (!_PyCheck_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + if (!_PyCheck_ENTITY_LIST(input_ent_list)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + API_BEGIN + + // Get the ACIS objects from the user input + ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; + ENTITY_LIST *&_face_list = ((a3dp_ENTITY_LIST *) input_ent_list)->_acis_obj; + + // Call ACIS function + result = api_get_faces(_ent, *_face_list); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } + +} + +PyObject * +a3dp_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_ent = NULL, *input_ent_list = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ent", + (char *) "edge_list", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) + return NULL; + + if (!_PyCheck_ENTITY(input_ent)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); + return NULL; + } + + if (!_PyCheck_ENTITY_LIST(input_ent_list)) + { + PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); + return NULL; + } + + API_BEGIN + + // Get the ACIS objects from the user input + ENTITY *&_ent = ((a3dp_ENTITY *) input_ent)->_acis_obj; + ENTITY_LIST *&_edge_list = ((a3dp_ENTITY_LIST *) input_ent_list)->_acis_obj; + + // Call ACIS function + result = api_get_edges(_ent, *_edge_list); + + API_END + + // Check outcome + if (!check_outcome(result)) + { + // Returning NULL means that we have an error + return NULL; + } + else + { + // Returning none means that we have no errors + Py_RETURN_NONE; + } + +} diff --git a/src/acis_api.h b/src/acis_api.h new file mode 100644 index 0000000..0e7f970 --- /dev/null +++ b/src/acis_api.h @@ -0,0 +1,65 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_API_H +#define A3DPY_API_H + +#include +#include + +#include "acis_includes.h" +#include "acis_entity.h" +#include "acis_operators.h" +#include "acis_classes.h" +#include "acis_enums.h" +#include "acis_spa.h" +#include "utilities.h" + +#ifdef __cplusplus +extern "C" { +#endif + +PyObject *a3dp_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_stop_modeller(PyObject *self); +PyObject *a3dp_is_modeler_started(PyObject *self); +PyObject *a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_unite(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_API_H diff --git a/src/acis_booleans.cpp b/src/acis_booleans.cpp deleted file mode 100644 index 930c3d8..0000000 --- a/src/acis_booleans.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "acis_booleans.h" - - -/** - * NDBOOL_KEEP enum - */ - -static PyTypeObject - ACIS_Booleans_type_NDBOOL_KEEP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.NDBOOL_KEEP", /* tp_name */ - sizeof(ACIS_Booleans_NDBOOL_KEEP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ - }; - - -/** - * Booleans API Interface Functions - */ - -static PyObject * -ACIS_api_unite(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_unite(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_intersect(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_subtract(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_tool = NULL, *input_blank = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "tool", - (char *) "blank", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_tool, &input_blank)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tool)) - { - PyErr_SetString(PyExc_TypeError, "Tool must be a BODY object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_blank)) - { - PyErr_SetString(PyExc_TypeError, "Blank must be a BODY object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tool = (BODY *&) ((ACIS_Entity_BODY *) input_tool)->base_obj._acis_obj; - BODY *&_blank = (BODY *&) ((ACIS_Entity_BODY *) input_blank)->base_obj._acis_obj; - - // Call ACIS API - result = api_imprint(_tool, _blank); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _ACIS_make_null(input_tool); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_boolean_chop_body(PyObject *self, PyObject *args, PyObject *kwargs) -{ - /* TO-DO: Implement api_boolean_chop_body */ - return NULL; -} - -static PyMethodDef - module_methods[] = - { - { "api_unite", (PyCFunction) ACIS_api_unite, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean unite operation" }, - { "api_intersect", (PyCFunction) ACIS_api_intersect, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean intersect operation on two bodies" }, - { "api_subtract", (PyCFunction) ACIS_api_subtract, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean subtract operation" }, - { "api_imprint", (PyCFunction) ACIS_api_imprint, METH_VARARGS | METH_KEYWORDS, "Intersects two bodies and imprints the intersection graph on both bodies" }, - { "api_boolean_chop_body", (PyCFunction) ACIS_api_boolean_chop_body, METH_VARARGS | METH_KEYWORDS, "Executes simultaneous Boolean intersect and subtract operations on two bodies" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Booleans"; -const char *module_documentation = "Contains 3D ACIS Modeler booleans API related classes and functions"; - -static struct PyModuleDef - ACIS_Booleans_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Booleans(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Booleans_module); - if (m == NULL) - return NULL; - - // Create a dictionary object for NDBOOL_KEEP enum - PyObject *_ndbk_dict; - _ndbk_dict = PyDict_New(); - if (_ndbk_dict != NULL) - { - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_NEITHER", PyLong_FromLong(0L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_TOOL", PyLong_FromLong(1L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BLANK", PyLong_FromLong(2L)); - PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BOTH", PyLong_FromLong(3L)); - } - - // sweep_bool_type - ACIS_Booleans_type_NDBOOL_KEEP.tp_dict = _ndbk_dict; - if (PyType_Ready(&ACIS_Booleans_type_NDBOOL_KEEP) < 0) - return NULL; - Py_INCREF(&ACIS_Booleans_type_NDBOOL_KEEP); - PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &ACIS_Booleans_type_NDBOOL_KEEP); - - return m; -} - -PyObject *_ACIS_new_NDBOOL_KEEP() -{ - return PyObject_CallObject((PyObject *) &ACIS_Booleans_type_NDBOOL_KEEP, NULL); -} - -bool _ACIS_check_NDBOOL_KEEP(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Booleans_type_NDBOOL_KEEP; -} \ No newline at end of file diff --git a/src/acis_booleans.h b/src/acis_booleans.h deleted file mode 100644 index 85520ca..0000000 --- a/src/acis_booleans.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_BOOLEANS_H -#define ACIS_BOOLEANS_H - -#include -#include - -#include - -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "utilities.h" - -#include "acis_booleans_export.h" - -// Define NDBOOL_KEEP enum -typedef struct { - PyObject_HEAD -} ACIS_Booleans_NDBOOL_KEEP; - -PyObject ACIS_BOOLEANS_EXPORT *_ACIS_new_NDBOOL_KEEP(); - -bool ACIS_BOOLEANS_EXPORT _ACIS_check_NDBOOL_KEEP(PyObject *ob); - - -#endif // !ACIS_BOOLEANS_H diff --git a/src/acis_classes.cpp b/src/acis_classes.cpp new file mode 100644 index 0000000..049a475 --- /dev/null +++ b/src/acis_classes.cpp @@ -0,0 +1,1694 @@ +#include "acis_classes.h" + + + +/** + * SPAposition wrapper + */ + +void +a3dp_SPAposition_dealloc(a3dp_SPAposition *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAposition *self; + + self = (a3dp_SPAposition *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAposition(input_x, input_y, input_z); + + return 0; +} + +PyObject * +a3dp_SPAposition_repr(a3dp_SPAposition *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAposition object (%s, %s, %s)", _x, _y, _z); +} + +PyObject * +a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->coordinate(_i)); +} + +PyObject * +a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The coordinate input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_coordinate(_i, _new_c); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAposition__x(a3dp_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +PyObject * +a3dp_SPAposition__y(a3dp_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +PyObject * +a3dp_SPAposition__z(a3dp_SPAposition *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +PyObject * +a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + return a3dp_SPAposition__x(self); +} + +PyObject * +a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + return a3dp_SPAposition__y(self); +} + +PyObject * +a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + return a3dp_SPAposition__z(self); +} + +int +a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + a3dp_SPAposition__set_x(self, value); + return 0; +} + +int +a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + a3dp_SPAposition__set_y(self, value); + return 0; +} + +int +a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure) +{ + a3dp_SPAposition__set_z(self, value); + return 0; +} + +bool _PyCheck_SPAposition(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAposition; +} + +PyObject *_PyNew_SPAposition() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAposition, NULL); +} + +/** + * SPAvector class + */ + +void +a3dp_SPAvector_dealloc(a3dp_SPAvector *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAvector *self; + + self = (a3dp_SPAvector *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAvector(input_x, input_y, input_z); + + return 0; +} + +PyObject * +a3dp_SPAvector_repr(a3dp_SPAvector *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAvector object (%s, %s, %s)", _x, _y, _z); +} + +PyObject * +a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->component(_i)); +} + +PyObject * +a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_component(_i, _new_c); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAvector__x(a3dp_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +PyObject * +a3dp_SPAvector__y(a3dp_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +PyObject * +a3dp_SPAvector__z(a3dp_SPAvector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +PyObject * +a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + return a3dp_SPAvector__x(self); +} + +PyObject * +a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + return a3dp_SPAvector__y(self); +} + +PyObject * +a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + return a3dp_SPAvector__z(self); +} + +int +a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + a3dp_SPAvector__set_x(self, value); + return 0; +} + +int +a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + a3dp_SPAvector__set_y(self, value); + return 0; +} + +int +a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure) +{ + a3dp_SPAvector__set_z(self, value); + return 0; +} + +bool _PyCheck_SPAvector(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAvector; +} + +PyObject *_PyNew_SPAvector() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAvector, NULL); +} + +/** + * SPAunit_vector wrapper + */ + +void +a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAunit_vector *self; + + self = (a3dp_SPAunit_vector *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) +{ + double input_x = 0.0, input_y = 0.0, input_z = 0.0; + + char *kwlist[] = + { + (char *) "x", + (char *) "y", + (char *) "z", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) + return -1; + + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAunit_vector(input_x, input_y, input_z); + + return 0; +} + +PyObject * +a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self) +{ + double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); + + char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_x) + return PyErr_NoMemory(); + + char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_y) + return PyErr_NoMemory(); + + char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_z) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPAunit_vector object (%s, %s, %s)", _x, _y, _z); +} + +PyObject * +a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + // No parsing required as this function takes exactly 1 argument + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + int _i = (int) PyLong_AsLong(arg); + + // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); + return NULL; + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Return data from the ACIS object + return PyFloat_FromDouble(self->_acis_obj->component(_i)); +} + +PyObject * +a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) +{ + int _i; + double _new_c; + + char *kwlist[] = + { + (char *) "i", + (char *) "new_c", + NULL + }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) + return NULL; + + // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z + if (_i < 0 || _i > 2) + { + PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); + return NULL; + } + + self->_acis_obj->set_component(_i, _new_c); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_x(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_y(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg) +{ + // Treat arg as a borrowed reference + Py_INCREF(arg); + + double _value; + + // No parsing required as this function takes exactly 1 argument + if (PyFloat_Check(arg)) + { + _value = PyFloat_AsDouble(arg); + } + else + { + if (PyLong_Check(arg)) + { + _value = PyLong_AsDouble(arg); + } + else + { + PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); + return NULL; + } + } + + self->_acis_obj->set_z(_value); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->x()); +} + +PyObject * +a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->y()); +} + +PyObject * +a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self) +{ + return PyFloat_FromDouble(self->_acis_obj->z()); +} + +PyObject * +a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + return a3dp_SPAunitvector__x(self); +} + +PyObject * +a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + return a3dp_SPAunitvector__y(self); +} + +PyObject * +a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + return a3dp_SPAunitvector__z(self); +} + +int +a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + a3dp_SPAunitvector__set_x(self, value); + return 0; +} + +int +a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + a3dp_SPAunitvector__set_y(self, value); + return 0; +} + +int +a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) +{ + a3dp_SPAunitvector__set_z(self, value); + return 0; +} + +bool _PyCheck_SPAunit_vector(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAunitvector; +} + +PyObject *_PyNew_SPAunit_vector() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAunitvector, NULL); +} + +/** + * SPAmatrix wrapper + */ + +void +a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAmatrix *self; + + self = (a3dp_SPAmatrix *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAmatrix(); + + return 0; +} + +PyObject * +a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg) +{ + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + // Create a new SPAvector python object + PyObject *_python_ret = _PyNew_SPAvector(); + + // Convert python input argument into a C variable + int _in_col = (int) PyLong_AsLong(arg); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->column(_in_col); + + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg) +{ + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); + return NULL; + } + + // Create a new SPAvector python object + PyObject *_python_ret = _PyNew_SPAvector(); + + // Convert python input argument into a C variable + int _in_row = (int) PyLong_AsLong(arg); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->row(_in_row); + + // Treat the input argument as a borrowed reference + Py_INCREF(arg); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self) +{ + // Create a new SPAmatrix python object + PyObject *_python_ret = _PyNew_SPAmatrix(); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->inverse(); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self) +{ + // Create a new SPAmatrix python object + PyObject *_python_ret = _PyNew_SPAmatrix(); + + // Execute the ACIS function and set ACIS variable inside the new python object + *((a3dp_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->transpose(); + + // Return the updated python object + return _python_ret; +} + +PyObject * +a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self) +{ + // Execute the ACIS function and return the value as a python object + return PyFloat_FromDouble(self->_acis_obj->determinant()); +} + +PyObject * +a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + int input_row, input_col; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "row", + (char *) "col", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_row, &input_col)) + return NULL; + + // Execute the ACIS function and return the value as a python object + return PyFloat_FromDouble(self->_acis_obj->element(input_row, input_col)); +} + +PyObject * +a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) +{ + int input_row, input_col; + double input_new_e; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "row", + (char *) "col", + (char *) "new_e", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iid", kwlist, &input_row, &input_col, &input_new_e)) + return NULL; + + // Execute the ACIS function + self->_acis_obj->set_element(input_row, input_col, input_new_e); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self) +{ + logical _ret_val = self->_acis_obj->is_identity(); + + if (_ret_val) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +bool _PyCheck_SPAmatrix(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAmatrix; +} + +PyObject *_PyNew_SPAmatrix() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAmatrix, NULL); +} + +/** + * SPAtransf wrapper + */ + +void +a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPAtransf *self; + + self = (a3dp_SPAtransf *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPAtransf(); + + return 0; +} + +PyObject * +a3dp_SPAtransf__affine(a3dp_SPAtransf *self) +{ + PyObject *_ret = _PyNew_SPAmatrix(); + + *((a3dp_SPAmatrix *) _ret)->_acis_obj = self->_acis_obj->affine(); + + return _ret; +} + +PyObject * +a3dp_SPAtransf__inverse(a3dp_SPAtransf *self) +{ + PyObject *_ret = _PyNew_SPAtransf(); + + *((a3dp_SPAtransf *) _ret)->_acis_obj = self->_acis_obj->inverse(); + + return _ret; +} + +PyObject * +a3dp_SPAtransf__translation(a3dp_SPAtransf *self) +{ + PyObject *_ret = _PyNew_SPAvector(); + + *((a3dp_SPAvector *) _ret)->_acis_obj = self->_acis_obj->translation(); + + return _ret; +} + +PyObject * +a3dp_SPAtransf__identity(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->identity(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_SPAtransf__reflect(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->reflect(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_SPAtransf__rotate(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->rotate(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +PyObject * +a3dp_SPAtransf__scaling(a3dp_SPAtransf *self) +{ + return PyFloat_FromDouble(self->_acis_obj->scaling()); +} + +PyObject * +a3dp_SPAtransf__shear(a3dp_SPAtransf *self) +{ + logical _check = self->_acis_obj->shear(); + + if (_check) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + + +bool _PyCheck_SPAtransf(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAtransf; +} + +PyObject *_PyNew_SPAtransf() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAtransf, NULL); +} + +/** + * SPApar_pos wrapper + */ + +void +a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPApar_pos *self; + + self = (a3dp_SPApar_pos *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPApar_pos(); + + return 0; +} + +PyObject * +a3dp_SPAparpos_repr(a3dp_SPApar_pos *self) +{ + double u = self->_acis_obj->u; double v = self->_acis_obj->v; + + char *_u = PyOS_double_to_string(u, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_u) + return PyErr_NoMemory(); + + char *_v = PyOS_double_to_string(v, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_v) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPApar_pos object (%s, %s)", _u, _v); +} + +PyObject * +a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->u); +} + +int +a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + self->_acis_obj->u = PyFloat_AsDouble(value); + return 0; +} + +PyObject * +a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->v); +} + +int +a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) +{ + self->_acis_obj->v = PyFloat_AsDouble(value); + return 0; +} + +bool _PyCheck_SPApar_pos(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAparpos; +} + +PyObject *_PyNew_SPApar_pos() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAparpos, NULL); +} + +/** + * SPApar_vec wrapper + */ + +void +a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_SPApar_vec *self; + + self = (a3dp_SPApar_vec *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW SPApar_vec(); + + return 0; +} + +PyObject * +a3dp_SPAparvec_repr(a3dp_SPApar_vec *self) +{ + double du = self->_acis_obj->du; double dv = self->_acis_obj->dv; + + char *_du = PyOS_double_to_string(du, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_du) + return PyErr_NoMemory(); + + char *_dv = PyOS_double_to_string(dv, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + if (!_dv) + return PyErr_NoMemory(); + + return PyUnicode_FromFormat("SPApar_vec object (%s, %s)", _du, _dv); +} + +PyObject * +a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->du); +} + +int +a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + self->_acis_obj->du = PyFloat_AsDouble(value); + return 0; +} + +PyObject * +a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + return PyFloat_FromDouble(self->_acis_obj->dv); +} + +int +a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) +{ + self->_acis_obj->dv = PyFloat_AsDouble(value); + return 0; +} + +bool _PyCheck_SPApar_vec(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SPAparvec; +} + +PyObject *_PyNew_SPApar_vec() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPAparvec, NULL); +} + + +/** + * FileInfo class + */ + +void +a3dp_FileInfo_dealloc(a3dp_FileInfo *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + // Delete the python object itself + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_FileInfo *self; + + self = (a3dp_FileInfo *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + self->_acis_obj = ACIS_NEW FileInfo(); + return 0; +} + +PyObject * +a3dp_FileInfo__acis_version(a3dp_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->acis_version()); +} + +PyObject * +a3dp_FileInfo__date(a3dp_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->date()); +} + +PyObject * +a3dp_FileInfo__file_version(a3dp_FileInfo *self) +{ + return PyLong_FromLong((long) self->_acis_obj->file_version()); +} + +PyObject * +a3dp_FileInfo__product_id(a3dp_FileInfo *self) +{ + return PyUnicode_FromString(self->_acis_obj->product_id()); +} + +PyObject * +a3dp_FileInfo__reset(a3dp_FileInfo *self) +{ + self->_acis_obj->reset(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__reset_vars(a3dp_FileInfo *self) +{ + self->_acis_obj->reset_vars(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__restore(a3dp_FileInfo *self) +{ + self->_acis_obj->restore(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__save(a3dp_FileInfo *self) +{ + self->_acis_obj->save(); + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + unsigned long input_field; + PyObject *input_file = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "field", + (char *) "file", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "lO", kwlist, &input_field, &input_file)) + return NULL; + + // Check if the user input is a FileInfo object + if (_PyCheck_FileInfo(input_file)) + { + PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); + return NULL; + } + + // Convert PyObject to ENTITY_LIST + FileInfo *_file = ((a3dp_FileInfo *) input_file)->_acis_obj; + + // Execute ACIS function + self->_acis_obj->set_masked(input_field, *_file); + + // Return None + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + const char *input_id = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "id", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &input_id)) + return NULL; + + self->_acis_obj->set_product_id(input_id); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) +{ + double input_count; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "count", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_count)) + return NULL; + + self->_acis_obj->set_units(input_count); + + Py_RETURN_NONE; +} + +PyObject * +a3dp_FileInfo__tol_abs(a3dp_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->tol_abs()); +} + +PyObject * +a3dp_FileInfo__tol_nor(a3dp_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->tol_nor()); +} + +PyObject * +a3dp_FileInfo__units(a3dp_FileInfo *self) +{ + return PyFloat_FromDouble(self->_acis_obj->units()); +} + +PyObject * +a3dp_FileInfo__valid(a3dp_FileInfo *self) +{ + self->_acis_obj->valid(); + Py_RETURN_NONE; +} + +bool +_PyCheck_FileInfo(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_FileInfo; +} + +void +a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_make_sweep_path_options *self; + + self = (a3dp_make_sweep_path_options *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW make_sweep_path_options(); + + return 0; +} + +void +a3dp_sweepoptions_dealloc(a3dp_sweep_options *self) +{ + // Delete ACIS object + ACIS_DELETE self->_acis_obj; + + Py_TYPE(self)->tp_free((PyObject *) self); +} + +PyObject * +a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + a3dp_sweep_options *self; + + self = (a3dp_sweep_options *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; +} + +int +a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) +{ + // Initialize the ACIS object + self->_acis_obj = ACIS_NEW sweep_options(); + + return 0; +} + +PyObject * +a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) +{ + // Just a testing... + self->_acis_obj->set_bool_type(KEEP_BOTH); + + Py_RETURN_NONE; +} + + +PyObject * +_PyNew_make_sweep_path_options() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_make_sweep_path_options, NULL); +} + +bool +_PyCheck_make_sweep_path_options(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_make_sweep_path_options; +} + +PyObject * +_PyNew_sweep_options() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_sweep_options, NULL); +} + +bool +_PyCheck_sweep_options(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_sweep_options; +} diff --git a/src/acis_classes.h b/src/acis_classes.h new file mode 100644 index 0000000..fff4746 --- /dev/null +++ b/src/acis_classes.h @@ -0,0 +1,841 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_CLASSES_H +#define A3DPY_CLASSES_H + +#include +#include + +#include "acis_includes.h" +#include "utilities.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// Define SPAposition +typedef struct +{ + PyObject_HEAD + SPAposition *_acis_obj; +} a3dp_SPAposition; + +void a3dp_SPAposition_dealloc(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAposition_repr(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg); +PyObject *a3dp_SPAposition__x(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition__y(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition__z(a3dp_SPAposition *self); +PyObject *a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure); +PyObject *a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure); +PyObject *a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure); +int a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure); +int a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure); +int a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAposition[] = + { + { (char *) "x_value", (getter) a3dp_SPAposition_x_getter, (setter) a3dp_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, + { (char *) "y_value", (getter) a3dp_SPAposition_y_getter, (setter) a3dp_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, + { (char *) "z_value", (getter) a3dp_SPAposition_z_getter, (setter) a3dp_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAposition[] = + { + { "coordinate", (PyCFunction) a3dp_SPAposition__coordinate, METH_O, "Returns the i-th component value" }, + { "set_coordinate", (PyCFunction) a3dp_SPAposition__set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, + { "set_x", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the x-coordinate value" }, + { "set_y", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the y-coordinate value" }, + { "set_z", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the z-coordinate value" }, + { "x", (PyCFunction) a3dp_SPAposition__x, METH_NOARGS, "Returns the x-coordinate value" }, + { "y", (PyCFunction) a3dp_SPAposition__y, METH_NOARGS, "Returns the y-coordinate value" }, + { "z", (PyCFunction) a3dp_SPAposition__z, METH_NOARGS, "Returns the z-coordinate value" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAposition = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAposition", /* tp_name */ + sizeof(a3dp_SPAposition), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAposition_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAposition_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAposition_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAposition, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAposition, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAposition_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAposition_new, /* tp_new */ + }; + + +PyObject *_PyNew_SPAposition(); + +bool _PyCheck_SPAposition(PyObject *ob); + +// Define SPAvector +typedef struct +{ + PyObject_HEAD + SPAvector *_acis_obj; +} a3dp_SPAvector; + +void a3dp_SPAvector_dealloc(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAvector_repr(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg); +PyObject *a3dp_SPAvector__x(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector__y(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector__z(a3dp_SPAvector *self); +PyObject *a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure); +int a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure); +int a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure); +int a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAvector[] = + { + { (char *) "x_value", (getter) a3dp_SPAvector_x_getter, (setter) a3dp_SPAvector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) a3dp_SPAvector_y_getter, (setter) a3dp_SPAvector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) a3dp_SPAvector_z_getter, (setter) a3dp_SPAvector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAvector[] = + { + { "component", (PyCFunction) a3dp_SPAvector__component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) a3dp_SPAvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) a3dp_SPAvector__x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) a3dp_SPAvector__y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) a3dp_SPAvector__z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAvector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAvector", /* tp_name */ + sizeof(a3dp_SPAvector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAvector_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAvector_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAvector_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAvector, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAvector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAvector_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAvector_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAvector(); + +bool _PyCheck_SPAvector(PyObject *ob); + +// Define SPAunit_vector +typedef struct +{ + PyObject_HEAD + SPAunit_vector *_acis_obj; +} a3dp_SPAunit_vector; + +void a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg); +PyObject *a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self); +PyObject *a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +PyObject *a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +int a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +int a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); +int a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAunit_vector[] = + { + { (char *) "x_value", (getter) a3dp_SPAunitvector_x_getter, (setter) a3dp_SPAunitvector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) a3dp_SPAunitvector_y_getter, (setter) a3dp_SPAunitvector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) a3dp_SPAunitvector_z_getter, (setter) a3dp_SPAunitvector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAunit_vector[] = + { + { "component", (PyCFunction) a3dp_SPAunitvector__component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) a3dp_SPAunitvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) a3dp_SPAunitvector__x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) a3dp_SPAunitvector__y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) a3dp_SPAunitvector__z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAunitvector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAunit_vector", /* tp_name */ + sizeof(a3dp_SPAunit_vector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAunitvector_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAunitvector_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAunitvector_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAunit_vector, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAunit_vector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAunitvector_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAunitvector_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAunit_vector(); + +bool _PyCheck_SPAunit_vector(PyObject *ob); + +// Define SPAmatrix +typedef struct +{ + PyObject_HEAD + SPAmatrix *_acis_obj; +} a3dp_SPAmatrix; + +void a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg); +PyObject *a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg); +PyObject *a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self); +PyObject *a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self); + +static PyMethodDef + a3dp_methods_SPAmatrix[] = + { + { "column", (PyCFunction) a3dp_SPAmatrix__column, METH_O, "Extracts a column from this matrix" }, + { "row", (PyCFunction) a3dp_SPAmatrix__row, METH_O, "Extracts a row from this matrix" }, + { "element", (PyCFunction) a3dp_SPAmatrix__element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, + { "set_element", (PyCFunction) a3dp_SPAmatrix__set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, + { "determinant", (PyCFunction) a3dp_SPAmatrix__determinant, METH_NOARGS, "Returns the determinant of this matrix" }, + { "transpose", (PyCFunction) a3dp_SPAmatrix__transpose, METH_NOARGS, "Returns a transpose of this matrix" }, + { "inverse", (PyCFunction) a3dp_SPAmatrix__inverse, METH_NOARGS, "Returns the inverse of this matrix" }, + { "is_identity", (PyCFunction) a3dp_SPAmatrix__is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAmatrix = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAmatrix", /* tp_name */ + sizeof(a3dp_SPAmatrix), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAmatrix_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAmatrix, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAmatrix_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAmatrix_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAmatrix(); + +bool _PyCheck_SPAmatrix(PyObject *ob); + +// Define SPAtransf +typedef struct +{ + PyObject_HEAD + SPAtransf *_acis_obj; +} a3dp_SPAtransf; + +void a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAtransf__affine(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__inverse(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__translation(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__identity(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__reflect(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__rotate(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__scaling(a3dp_SPAtransf *self); +PyObject *a3dp_SPAtransf__shear(a3dp_SPAtransf *self); + +static PyMethodDef + a3dp_methods_SPAtransf[] = + { + { "affine", (PyCFunction) a3dp_SPAtransf__affine, METH_NOARGS, "Returns the affine portion of the transformation" }, + { "inverse", (PyCFunction) a3dp_SPAtransf__inverse, METH_NOARGS, "Returns the inverse transformation" }, + { "translation", (PyCFunction) a3dp_SPAtransf__translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, + { "identity", (PyCFunction) a3dp_SPAtransf__identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, + { "reflect", (PyCFunction) a3dp_SPAtransf__reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, + { "rotate", (PyCFunction) a3dp_SPAtransf__rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, + { "scaling", (PyCFunction) a3dp_SPAtransf__scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, + { "shear", (PyCFunction) a3dp_SPAtransf__shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAtransf = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(a3dp_SPAtransf), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAtransf_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAtransf represents a general 3D affine transformation", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAtransf, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAtransf_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAtransf_new, /* tp_new */ + }; + +PyObject *_PyNew_SPAtransf(); + +bool _PyCheck_SPAtransf(PyObject *ob); + +// Define SPApar_pos +typedef struct +{ + PyObject_HEAD + SPApar_pos *_acis_obj; +} a3dp_SPApar_pos; + +void a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self); +PyObject *a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAparpos_repr(a3dp_SPApar_pos *self); +PyObject *a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); +int a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); +PyObject *a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); +int a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAparpos[] = + { + { (char *) "u", (getter) a3dp_SPAparpos_u_getter, (setter) a3dp_SPAparpos_u_setter, (char *) "value of the u parameter", NULL }, + { (char *) "v", (getter) a3dp_SPAparpos_v_getter, (setter) a3dp_SPAparpos_v_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAparpos = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(a3dp_SPApar_pos), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAparpos_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAparpos_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAparpos_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAparpos, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAparpos_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAparpos_new, /* tp_new */ + }; + +PyObject *_PyNew_SPApar_pos(); + +bool _PyCheck_SPApar_pos(PyObject *ob); + +// Define SPApar_vec +typedef struct +{ + PyObject_HEAD + SPApar_vec *_acis_obj; +} a3dp_SPApar_vec; + +void a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self); +PyObject *a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPAparvec_repr(a3dp_SPApar_vec *self); +PyObject *a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); +int a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); +PyObject *a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); +int a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); + +static PyGetSetDef + a3dp_getseters_SPAparvec[] = + { + { (char *) "du", (getter) a3dp_SPAparvec_du_getter, (setter) a3dp_SPAparvec_du_setter, (char *) "value of the u parameter", NULL }, + { (char *) "dv", (getter) a3dp_SPAparvec_dv_getter, (setter) a3dp_SPAparvec_dv_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_SPAparvec = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPApar_vec", /* tp_name */ + sizeof(a3dp_SPApar_vec), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAparvec_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAparvec_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAparvec_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAparvec, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAparvec_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAparvec_new, /* tp_new */ + }; + +PyObject *_PyNew_SPApar_vec(); + +bool _PyCheck_SPApar_vec(PyObject *ob); + +// Define FileInfo +typedef struct +{ + PyObject_HEAD + FileInfo *_acis_obj; +} a3dp_FileInfo; + +void a3dp_FileInfo_dealloc(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__acis_version(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__date(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__file_version(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__product_id(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__reset(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__reset_vars(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__restore(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__save(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FileInfo__tol_abs(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__tol_nor(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__units(a3dp_FileInfo *self); +PyObject *a3dp_FileInfo__valid(a3dp_FileInfo *self); + +static PyMemberDef + a3dp_members_FileInfo[] = + { + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_FileInfo[] = + { + { "acis_version", (PyCFunction) a3dp_FileInfo__acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, + { "date", (PyCFunction) a3dp_FileInfo__date, METH_NOARGS, "Returns the date on the save file" }, + { "file_version", (PyCFunction) a3dp_FileInfo__file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, + { "product_id", (PyCFunction) a3dp_FileInfo__product_id, METH_NOARGS, "Returns the ID of the product" }, + { "reset", (PyCFunction) a3dp_FileInfo__reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, + { "reset_vars", (PyCFunction) a3dp_FileInfo__reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, + { "restore", (PyCFunction) a3dp_FileInfo__restore, METH_NOARGS, "Restores the file information from a save file" }, + { "save", (PyCFunction) a3dp_FileInfo__save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, + //{ "set_masked", (PyCFunction)a3dp_FileInfo__set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, + { "set_product_id", (PyCFunction) a3dp_FileInfo__set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, + { "set_units", (PyCFunction) a3dp_FileInfo__set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, + { "tol_abs", (PyCFunction) a3dp_FileInfo__tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, + { "tol_nor", (PyCFunction) a3dp_FileInfo__tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, + { "units", (PyCFunction) a3dp_FileInfo__units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, + { "valid", (PyCFunction) a3dp_FileInfo__valid, METH_NOARGS, "Checks the values of the units and product id" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_FileInfo = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FileInfo", /* tp_name */ + sizeof(a3dp_FileInfo), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_FileInfo_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "FileInfo object contains additional required save file header information", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_FileInfo, /* tp_methods */ + a3dp_members_FileInfo, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_FileInfo_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_FileInfo_new, /* tp_new */ + }; + +bool _PyCheck_FileInfo(PyObject *ob); + +// Define sweep_options +typedef struct +{ + PyObject_HEAD + sweep_options *_acis_obj; +} a3dp_sweep_options; + +void a3dp_sweepoptions_dealloc(a3dp_sweep_options *self); +PyObject *a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); + +static PyMethodDef + a3dp_methods_sweepoptions[] = + { + { "set_bool_type", (PyCFunction) a3dp_sweepoptions__set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_sweep_options = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_options", /* tp_name */ + sizeof(a3dp_sweep_options), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_sweepoptions_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_sweepoptions, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_sweepoptions_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_sweepoptions_new, /* tp_new */ + }; + +PyObject *_PyNew_sweep_options(); +bool _PyCheck_sweep_options(PyObject *ob); + +// Define make_sweep_path_options +typedef struct +{ + PyObject_HEAD + make_sweep_path_options *_acis_obj; +} a3dp_make_sweep_path_options; + +void a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self); +PyObject *a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs); + +static PyTypeObject + a3dp_type_make_sweep_path_options = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.make_sweep_path_options", /* tp_name */ + sizeof(a3dp_make_sweep_path_options), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_makesweeppathoptions_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_makesweeppathoptions_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_makesweeppathoptions_new, /* tp_new */ + }; + +PyObject *_PyNew_make_sweep_path_options(); +bool _PyCheck_make_sweep_path_options(PyObject *ob); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_CLASSES_H diff --git a/src/acis_entity.cpp b/src/acis_entity.cpp index 677e3cf..e9f61a5 100644 --- a/src/acis_entity.cpp +++ b/src/acis_entity.cpp @@ -2,11 +2,11 @@ /** - * 3D ACIS Modeler - ENTITY wrapper + * ENTITY class */ int -ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg) +a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg) { // Use Py_VISIT macro for PyObject-type variables Py_VISIT(self->attrib_name); @@ -16,7 +16,7 @@ ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg } int -ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_clear(a3dp_ENTITY *self) { // Set ACIS object to NULL to allow it automatically deleted by ACIS memory manager //self->_acis_obj = NULL; @@ -29,14 +29,14 @@ ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self) } void -ACIS_Entity_dealloc_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_dealloc(a3dp_ENTITY *self) { - ACIS_Entity_clear_ENTITY(self); + a3dp_ENTITY_clear(self); Py_TYPE(self)->tp_free((PyObject *) self); } PyObject * -ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs) +a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started if (!is_modeler_started()) @@ -45,9 +45,9 @@ ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs) return NULL; } - ACIS_Entity_ENTITY *self; + a3dp_ENTITY *self; - self = (ACIS_Entity_ENTITY *) type->tp_alloc(type, 0); + self = (a3dp_ENTITY *) type->tp_alloc(type, 0); if (self != NULL) { self->attrib_name = PyUnicode_FromString(""); @@ -72,13 +72,13 @@ ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs) } int -ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwargs) +a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs) { // PyObject *input_name = NULL; // PyObject *input_id = NULL; // PyObject *tmp; // -// static char *kwlist[] = +// char *kwlist[] = // { // (char *) "name", // (char *) "id", @@ -128,7 +128,7 @@ ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwar } PyObject * -ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_repr(a3dp_ENTITY *self) { const char *_name = PyUnicode_AsUTF8(self->attrib_name); int _id = (int) PyLong_AsLong(self->attrib_object_id); @@ -136,7 +136,7 @@ ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self) } PyObject * -ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self) +a3dp_ENTITY_str(a3dp_ENTITY *self) { const char *acis_obj_status = NULL; if (self->_acis_obj == NULL) @@ -148,14 +148,14 @@ ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self) } PyObject * -ACIS_Entity_method_ENTITY_get_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_name); return self->attrib_name; } int -ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) { @@ -188,21 +188,21 @@ ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *va } PyObject * -ACIS_Entity_method_ENTITY_type_name(PyObject *self) +a3dp_ENTITY_type_name(PyObject *self) { - const char *_retval = ((ACIS_Entity_ENTITY *)self)->_acis_obj->type_name(); + const char *_retval = ((a3dp_ENTITY *)self)->_acis_obj->type_name(); return PyUnicode_FromString(_retval); } PyObject * -ACIS_Entity_method_ENTITY_get_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_object_id); return self->attrib_object_id; } int -ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure) +a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) { @@ -239,29 +239,29 @@ ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject * /** - * 3D ACIS Modeler - BODY wrapper + * BODY class */ -static int -ACIS_Entity_init_BODY(ACIS_Entity_BODY *self, PyObject *args, PyObject *kwargs) +int +a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_BODY(ACIS_Entity_BODY *self) +PyObject * +a3dp_BODY_repr(a3dp_BODY *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("BODY object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_BODY(ACIS_Entity_BODY *self) +PyObject * +a3dp_BODY_str(a3dp_BODY *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -272,92 +272,31 @@ ACIS_Entity_str_BODY(ACIS_Entity_BODY *self) return PyUnicode_FromFormat("BODY object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_BODY[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_BODY[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_BODY[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_BODY = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.BODY", /* tp_name */ - sizeof(ACIS_Entity_BODY), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_BODY, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_BODY, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS BODY class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_BODY, /* tp_methods */ - ACIS_Entity_members_BODY, /* tp_members */ - ACIS_Entity_getseters_BODY, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_BODY, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - FACE wrapper + * FACE class */ -static int -ACIS_Entity_init_FACE(ACIS_Entity_FACE *self, PyObject *args, PyObject *kwargs) +int +a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_FACE(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE_repr(a3dp_FACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("FACE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_FACE(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE_str(a3dp_FACE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -368,8 +307,8 @@ ACIS_Entity_str_FACE(ACIS_Entity_FACE *self) return PyUnicode_FromFormat("FACE object (%s)", acis_obj_status); } -static PyObject * -ACIS_Entity_method_FACE_sense(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE__sense(a3dp_FACE *self) { logical _revbit; _revbit = ((FACE *) self->base_obj._acis_obj)->sense(); @@ -381,103 +320,40 @@ ACIS_Entity_method_FACE_sense(ACIS_Entity_FACE *self) Py_RETURN_FALSE; } -static PyObject * -ACIS_Entity_method_FACE_geometry(ACIS_Entity_FACE *self) +PyObject * +a3dp_FACE__geometry(a3dp_FACE *self) { - PyObject *_retobj = _ACIS_new_SURFACE(); + PyObject *_retobj = _PyNew_SURFACE(); // Store everything as ENTITY - ((ACIS_Entity_SURFACE *) _retobj)->base_obj._acis_obj = (ENTITY *) ((FACE *) self->base_obj._acis_obj)->geometry(); + ((a3dp_SURFACE *) _retobj)->base_obj._acis_obj = (ENTITY *) ((FACE *) self->base_obj._acis_obj)->geometry(); return _retobj; } -static PyGetSetDef - ACIS_Entity_getseters_FACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_FACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_FACE[] = - { - { "sense", (PyCFunction) ACIS_Entity_method_FACE_sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, - { "geometry", (PyCFunction) ACIS_Entity_method_FACE_geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_FACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FACE", /* tp_name */ - sizeof(ACIS_Entity_FACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_FACE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_FACE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS FACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_FACE, /* tp_methods */ - ACIS_Entity_members_FACE, /* tp_members */ - ACIS_Entity_getseters_FACE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_FACE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - EDGE wrapper + * EDGE class */ -static int -ACIS_Entity_init_EDGE(ACIS_Entity_EDGE *self, PyObject *args, PyObject *kwargs) +int +a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_EDGE(ACIS_Entity_EDGE *self) +PyObject * +a3dp_EDGE_repr(a3dp_EDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("EDGE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_EDGE(ACIS_Entity_EDGE *self) +PyObject * +a3dp_EDGE_str(a3dp_EDGE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -488,92 +364,31 @@ ACIS_Entity_str_EDGE(ACIS_Entity_EDGE *self) return PyUnicode_FromFormat("EDGE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_EDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_EDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_EDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_EDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.EDGE", /* tp_name */ - sizeof(ACIS_Entity_EDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_EDGE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_EDGE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS EDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_EDGE, /* tp_methods */ - ACIS_Entity_members_EDGE, /* tp_members */ - ACIS_Entity_getseters_EDGE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_EDGE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - WIRE wrapper + * WIRE class */ -static int -ACIS_Entity_init_WIRE(ACIS_Entity_WIRE *self, PyObject *args, PyObject *kwargs) +int +a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_WIRE(ACIS_Entity_WIRE *self) +PyObject * +a3dp_WIRE_repr(a3dp_WIRE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("WIRE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_WIRE(ACIS_Entity_WIRE *self) +PyObject * +a3dp_WIRE_str(a3dp_WIRE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -584,92 +399,30 @@ ACIS_Entity_str_WIRE(ACIS_Entity_WIRE *self) return PyUnicode_FromFormat("WIRE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_WIRE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_WIRE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_WIRE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_WIRE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.WIRE", /* tp_name */ - sizeof(ACIS_Entity_WIRE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_WIRE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_WIRE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS WIRE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_WIRE, /* tp_methods */ - ACIS_Entity_members_WIRE, /* tp_members */ - ACIS_Entity_getseters_WIRE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_WIRE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - LUMP wrapper + * LUMP class */ -static int -ACIS_Entity_init_LUMP(ACIS_Entity_LUMP *self, PyObject *args, PyObject *kwargs) +int +a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_LUMP(ACIS_Entity_LUMP *self) +PyObject * +a3dp_LUMP_repr(a3dp_LUMP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("LUMP object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_LUMP(ACIS_Entity_LUMP *self) +PyObject * +a3dp_LUMP_str(a3dp_LUMP *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -680,92 +433,30 @@ ACIS_Entity_str_LUMP(ACIS_Entity_LUMP *self) return PyUnicode_FromFormat("LUMP object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_LUMP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_LUMP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_LUMP[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_LUMP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LUMP", /* tp_name */ - sizeof(ACIS_Entity_LUMP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_LUMP, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_LUMP, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LUMP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_LUMP, /* tp_methods */ - ACIS_Entity_members_LUMP, /* tp_members */ - ACIS_Entity_getseters_LUMP, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_LUMP, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SHELL wrapper + * SHELL class */ -static int -ACIS_Entity_init_SHELL(ACIS_Entity_SHELL *self, PyObject *args, PyObject *kwargs) +int +a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SHELL(ACIS_Entity_SHELL *self) +PyObject * +a3dp_SHELL_repr(a3dp_SHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SHELL object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SHELL(ACIS_Entity_SHELL *self) +PyObject * +a3dp_SHELL_str(a3dp_SHELL *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -776,92 +467,30 @@ ACIS_Entity_str_SHELL(ACIS_Entity_SHELL *self) return PyUnicode_FromFormat("SHELL object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SHELL", /* tp_name */ - sizeof(ACIS_Entity_SHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SHELL, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SHELL, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SHELL, /* tp_methods */ - ACIS_Entity_members_SHELL, /* tp_members */ - ACIS_Entity_getseters_SHELL, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SHELL, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SUBSHELL wrapper + * SUBSHELL class */ -static int -ACIS_Entity_init_SUBSHELL(ACIS_Entity_SUBSHELL *self, PyObject *args, PyObject *kwargs) +int +a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SUBSHELL(ACIS_Entity_SUBSHELL *self) +PyObject * +a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SUBSHELL object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SUBSHELL(ACIS_Entity_SUBSHELL *self) +PyObject * +a3dp_SUBSHELL_str(a3dp_SUBSHELL *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -872,92 +501,30 @@ ACIS_Entity_str_SUBSHELL(ACIS_Entity_SUBSHELL *self) return PyUnicode_FromFormat("SUBSHELL object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SUBSHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SUBSHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SUBSHELL[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SUBSHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SUBSHELL", /* tp_name */ - sizeof(ACIS_Entity_SUBSHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SUBSHELL, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SUBSHELL, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SUBSHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SUBSHELL, /* tp_methods */ - ACIS_Entity_members_SUBSHELL, /* tp_members */ - ACIS_Entity_getseters_SUBSHELL, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SUBSHELL, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - COEDGE wrapper + * COEDGE class */ -static int -ACIS_Entity_init_COEDGE(ACIS_Entity_COEDGE *self, PyObject *args, PyObject *kwargs) +int +a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_COEDGE(ACIS_Entity_COEDGE *self) +PyObject * +a3dp_COEDGE_repr(a3dp_COEDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("COEDGE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_COEDGE(ACIS_Entity_COEDGE *self) +PyObject * +a3dp_COEDGE_str(a3dp_COEDGE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -968,92 +535,31 @@ ACIS_Entity_str_COEDGE(ACIS_Entity_COEDGE *self) return PyUnicode_FromFormat("COEDGE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_COEDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_COEDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_COEDGE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_COEDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.COEDGE", /* tp_name */ - sizeof(ACIS_Entity_COEDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_COEDGE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_COEDGE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS COEDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_COEDGE, /* tp_methods */ - ACIS_Entity_members_COEDGE, /* tp_members */ - ACIS_Entity_getseters_COEDGE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_COEDGE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - /** - * 3D ACIS Modeler - LOOP wrapper + * LOOP class */ -static int -ACIS_Entity_init_LOOP(ACIS_Entity_LOOP *self, PyObject *args, PyObject *kwargs) +int +a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_LOOP(ACIS_Entity_LOOP *self) +PyObject * +a3dp_LOOP_repr(a3dp_LOOP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("LOOP object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_LOOP(ACIS_Entity_LOOP *self) +PyObject * +a3dp_LOOP_str(a3dp_LOOP *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1064,92 +570,30 @@ ACIS_Entity_str_LOOP(ACIS_Entity_LOOP *self) return PyUnicode_FromFormat("LOOP object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_LOOP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_LOOP[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_LOOP[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_LOOP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LOOP", /* tp_name */ - sizeof(ACIS_Entity_LOOP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_LOOP, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_LOOP, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LOOP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_LOOP, /* tp_methods */ - ACIS_Entity_members_LOOP, /* tp_members */ - ACIS_Entity_getseters_LOOP, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_LOOP, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - VERTEX wrapper + * VERTEX class */ -static int -ACIS_Entity_init_VERTEX(ACIS_Entity_VERTEX *self, PyObject *args, PyObject *kwargs) +int +a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_VERTEX(ACIS_Entity_VERTEX *self) +PyObject * +a3dp_VERTEX_repr(a3dp_VERTEX *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("VERTEX object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_VERTEX(ACIS_Entity_VERTEX *self) +PyObject * +a3dp_VERTEX_str(a3dp_VERTEX *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1160,92 +604,30 @@ ACIS_Entity_str_VERTEX(ACIS_Entity_VERTEX *self) return PyUnicode_FromFormat("VERTEX object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_VERTEX[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_VERTEX[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_VERTEX[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_VERTEX = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.VERTEX", /* tp_name */ - sizeof(ACIS_Entity_VERTEX), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_VERTEX, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_VERTEX, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS VERTEX class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_VERTEX, /* tp_methods */ - ACIS_Entity_members_VERTEX, /* tp_members */ - ACIS_Entity_getseters_VERTEX, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_VERTEX, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SURFACE wrapper + * SURFACE class */ -static int -ACIS_Entity_init_SURFACE(ACIS_Entity_SURFACE *self, PyObject *args, PyObject *kwargs) +int +a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SURFACE(ACIS_Entity_SURFACE *self) +PyObject * +a3dp_SURFACE_repr(a3dp_SURFACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SURFACE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SURFACE(ACIS_Entity_SURFACE *self) +PyObject * +a3dp_SURFACE_str(a3dp_SURFACE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1256,21 +638,21 @@ ACIS_Entity_str_SURFACE(ACIS_Entity_SURFACE *self) return PyUnicode_FromFormat("SURFACE object (%s)", acis_obj_status); } -static PyObject * -ACIS_Entity_method_SURFACE_equation(ACIS_Entity_SURFACE *self) +PyObject * +a3dp_SURFACE__equation(a3dp_SURFACE *self) { - PyObject *_retobj = _ACIS_new_surface(); - *((ACIS_Entity_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->equation(); + PyObject *_retobj = _PyNew_surface(); + *((a3dp_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->equation(); return _retobj; } -static PyObject * -ACIS_Entity_method_SURFACE_trans_surface(ACIS_Entity_SURFACE *self, PyObject *args, PyObject *kwargs) +PyObject * +a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) { PyObject *input_t = NULL, *input_reverse = NULL; // List of keyword arguments that this function can take - static char *kwlist[] = + char *kwlist[] = { (char *) "t", (char *) "reverse", @@ -1285,13 +667,13 @@ ACIS_Entity_method_SURFACE_trans_surface(ACIS_Entity_SURFACE *self, PyObject *ar if (input_t != NULL) { // Validate input - if (!_ACIS_check_SPAtransf(input_t)) + if (!_PyCheck_SPAtransf(input_t)) { PyErr_SetString(PyExc_TypeError, "The first argument (t) must be a SPAtransf object"); return NULL; } - _t = *((ACIS_GeometricAtoms_SPAtransf *) input_t)->_acis_obj; + _t = *((a3dp_SPAtransf *) input_t)->_acis_obj; } logical _reverse = FALSE; @@ -1301,99 +683,35 @@ ACIS_Entity_method_SURFACE_trans_surface(ACIS_Entity_SURFACE *self, PyObject *ar _reverse = (_py_inp_reverse == 0) ? FALSE : TRUE; } - PyObject *_retobj = _ACIS_new_surface(); - ((ACIS_Entity_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->trans_surface(_t, _reverse); + PyObject *_retobj = _PyNew_surface(); + ((a3dp_surface *) _retobj)->_acis_obj = ((SURFACE *)(self->base_obj._acis_obj))->trans_surface(_t, _reverse); return _retobj; } -static PyGetSetDef - ACIS_Entity_getseters_SURFACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SURFACE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SURFACE[] = - { - { "equation", (PyCFunction) ACIS_Entity_method_SURFACE_equation, METH_NOARGS, "Returns the equation of this SURFACE" }, - { "trans_surface", (PyCFunction) ACIS_Entity_method_SURFACE_trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SURFACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SURFACE", /* tp_name */ - sizeof(ACIS_Entity_SURFACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SURFACE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SURFACE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SURFACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SURFACE, /* tp_methods */ - ACIS_Entity_members_SURFACE, /* tp_members */ - ACIS_Entity_getseters_SURFACE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SURFACE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - CONE wrapper + * CONE class */ -static int -ACIS_Entity_init_CONE(ACIS_Entity_CONE *self, PyObject *args, PyObject *kwargs) +int +a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_CONE(ACIS_Entity_CONE *self) +PyObject * +a3dp_CONE_repr(a3dp_CONE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("CONE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_CONE(ACIS_Entity_CONE *self) +PyObject * +a3dp_CONE_str(a3dp_CONE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1404,92 +722,30 @@ ACIS_Entity_str_CONE(ACIS_Entity_CONE *self) return PyUnicode_FromFormat("CONE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_CONE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_CONE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_CONE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_CONE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.CONE", /* tp_name */ - sizeof(ACIS_Entity_CONE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_CONE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_CONE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS CONE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_CONE, /* tp_methods */ - ACIS_Entity_members_CONE, /* tp_members */ - ACIS_Entity_getseters_CONE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_CONE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - PLANE wrapper + * PLANE class */ -static int -ACIS_Entity_init_PLANE(ACIS_Entity_PLANE *self, PyObject *args, PyObject *kwargs) +int +a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_PLANE(ACIS_Entity_PLANE *self) +PyObject * +a3dp_PLANE_repr(a3dp_PLANE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("PLANE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_PLANE(ACIS_Entity_PLANE *self) +PyObject * +a3dp_PLANE_str(a3dp_PLANE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1500,92 +756,30 @@ ACIS_Entity_str_PLANE(ACIS_Entity_PLANE *self) return PyUnicode_FromFormat("PLANE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_PLANE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_PLANE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_PLANE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_PLANE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.PLANE", /* tp_name */ - sizeof(ACIS_Entity_PLANE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_PLANE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_PLANE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS PLANE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_PLANE, /* tp_methods */ - ACIS_Entity_members_PLANE, /* tp_members */ - ACIS_Entity_getseters_PLANE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_PLANE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SPHERE wrapper + * SPHERE class */ -static int -ACIS_Entity_init_SPHERE(ACIS_Entity_SPHERE *self, PyObject *args, PyObject *kwargs) +int +a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SPHERE(ACIS_Entity_SPHERE *self) +PyObject * +a3dp_SPHERE_repr(a3dp_SPHERE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SPHERE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SPHERE(ACIS_Entity_SPHERE *self) +PyObject * +a3dp_SPHERE_str(a3dp_SPHERE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1596,92 +790,30 @@ ACIS_Entity_str_SPHERE(ACIS_Entity_SPHERE *self) return PyUnicode_FromFormat("SPHERE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SPHERE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SPHERE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SPHERE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SPHERE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPHERE", /* tp_name */ - sizeof(ACIS_Entity_SPHERE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SPHERE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SPHERE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPHERE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SPHERE, /* tp_methods */ - ACIS_Entity_members_SPHERE, /* tp_members */ - ACIS_Entity_getseters_SPHERE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SPHERE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - SPLINE wrapper + * SPLINE class */ -static int -ACIS_Entity_init_SPLINE(ACIS_Entity_SPLINE *self, PyObject *args, PyObject *kwargs) +int +a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_SPLINE(ACIS_Entity_SPLINE *self) +PyObject * +a3dp_SPLINE_repr(a3dp_SPLINE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("SPLINE object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_SPLINE(ACIS_Entity_SPLINE *self) +PyObject * +a3dp_SPLINE_str(a3dp_SPLINE *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1692,92 +824,30 @@ ACIS_Entity_str_SPLINE(ACIS_Entity_SPLINE *self) return PyUnicode_FromFormat("SPLINE object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_SPLINE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_SPLINE[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_SPLINE[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_SPLINE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPLINE", /* tp_name */ - sizeof(ACIS_Entity_SPLINE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_SPLINE, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_SPLINE, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPLINE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_SPLINE, /* tp_methods */ - ACIS_Entity_members_SPLINE, /* tp_members */ - ACIS_Entity_getseters_SPLINE, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_SPLINE, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - TORUS wrapper + * TORUS class */ -static int -ACIS_Entity_init_TORUS(ACIS_Entity_TORUS *self, PyObject *args, PyObject *kwargs) +int +a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs) { // Initialize the base class - if (ACIS_Entity_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) + if (a3dp_type_ENTITY.tp_init((PyObject *) self, args, kwargs) < 0) return -1; return 0; } -static PyObject * -ACIS_Entity_repr_TORUS(ACIS_Entity_TORUS *self) +PyObject * +a3dp_TORUS_repr(a3dp_TORUS *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); int _id = (int) PyLong_AsLong(self->base_obj.attrib_object_id); return PyUnicode_FromFormat("TORUS object with name '%s' and ID '%i'", _name, _id); } -static PyObject * -ACIS_Entity_str_TORUS(ACIS_Entity_TORUS *self) +PyObject * +a3dp_TORUS_str(a3dp_TORUS *self) { const char *acis_obj_status = NULL; if (self->base_obj._acis_obj == NULL) @@ -1788,80 +858,18 @@ ACIS_Entity_str_TORUS(ACIS_Entity_TORUS *self) return PyUnicode_FromFormat("TORUS object (%s)", acis_obj_status); } -static PyGetSetDef - ACIS_Entity_getseters_TORUS[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_TORUS[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_TORUS[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Entity_type_TORUS = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.TORUS", /* tp_name */ - sizeof(ACIS_Entity_TORUS), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_TORUS, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_TORUS, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS TORUS class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_TORUS, /* tp_methods */ - ACIS_Entity_members_TORUS, /* tp_members */ - ACIS_Entity_getseters_TORUS, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_TORUS, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - /** - * 3D ACIS Modeler - surface wrapper + * surface class */ -static void -ACIS_Entity_dealloc_surface(ACIS_Entity_surface *self) +void +a3dp_surface_dealloc(a3dp_surface *self) { Py_TYPE(self)->tp_free((PyObject *) self); } -static PyObject * -ACIS_Entity_new_surface(PyTypeObject *type, PyObject *args, PyObject *kwargs) +PyObject * +a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started if (!is_modeler_started()) @@ -1870,9 +878,9 @@ ACIS_Entity_new_surface(PyTypeObject *type, PyObject *args, PyObject *kwargs) return NULL; } - ACIS_Entity_surface *self; + a3dp_surface *self; - self = (ACIS_Entity_surface *) type->tp_alloc(type, 0); + self = (a3dp_surface *) type->tp_alloc(type, 0); if (self != NULL) { // Just getting rid of the dangling pointer @@ -1882,16 +890,16 @@ ACIS_Entity_new_surface(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -static int -ACIS_Entity_init_surface(ACIS_Entity_surface *self, PyObject *args, PyObject *kwargs) +int +a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs) { return 0; } -static PyObject * -ACIS_Entity_method_surface_eval_normal(ACIS_Entity_surface *self, PyObject *arg) +PyObject * +a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg) { - if (!_ACIS_check_SPApar_pos(arg)) + if (!_PyCheck_SPApar_pos(arg)) { PyErr_SetString(PyExc_TypeError, "Expecting a SPApar_pos object"); return NULL; @@ -1899,22 +907,22 @@ ACIS_Entity_method_surface_eval_normal(ACIS_Entity_surface *self, PyObject *arg) Py_INCREF(arg); - SPApar_pos *&_pos = ((ACIS_GeometricAtoms_SPApar_pos *) arg)->_acis_obj; + SPApar_pos *&_pos = ((a3dp_SPApar_pos *) arg)->_acis_obj; SPAunit_vector _retval = self->_acis_obj->eval_normal(*_pos); - PyObject *_retobj = _ACIS_new_SPAunit_vector(); - *((ACIS_GeometricAtoms_SPAunit_vector *) _retobj)->_acis_obj = _retval; + PyObject *_retobj = _PyNew_SPAunit_vector(); + *((a3dp_SPAunit_vector *) _retobj)->_acis_obj = _retval; Py_DECREF(arg); return _retobj; } -static PyObject * -ACIS_Entity_method_surface_eval_position(ACIS_Entity_surface *self, PyObject *arg) +PyObject * +a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg) { - if (!_ACIS_check_SPApar_pos(arg)) + if (!_PyCheck_SPApar_pos(arg)) { PyErr_SetString(PyExc_TypeError, "Expecting a SPApar_pos object"); return NULL; @@ -1922,432 +930,540 @@ ACIS_Entity_method_surface_eval_position(ACIS_Entity_surface *self, PyObject *ar Py_INCREF(arg); - SPApar_pos *&_pos = ((ACIS_GeometricAtoms_SPApar_pos *) arg)->_acis_obj; + SPApar_pos *&_pos = ((a3dp_SPApar_pos *) arg)->_acis_obj; SPAposition _retval = self->_acis_obj->eval_position(*_pos); - PyObject *_retobj = _ACIS_new_SPAposition(); - *((ACIS_GeometricAtoms_SPAposition *) _retobj)->_acis_obj = _retval; + PyObject *_retobj = _PyNew_SPAposition(); + *((a3dp_SPAposition *) _retobj)->_acis_obj = _retval; Py_DECREF(arg); return _retobj; } -static PyGetSetDef - ACIS_Entity_getseters_surface[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_surface[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Entity_methods_surface[] = - { - { "eval_normal", (PyCFunction) ACIS_Entity_method_surface_eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, - { "eval_position", (PyCFunction) ACIS_Entity_method_surface_eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, - { NULL } /* Sentinel */ - }; +PyObject *_PyNew_ENTITY() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_ENTITY, NULL); +} -static PyTypeObject - ACIS_Entity_type_surface = +bool _PyCheck_ENTITY(PyObject *ob) +{ + int retval = PyObject_IsInstance(ob, (PyObject *) &a3dp_type_ENTITY); + if (retval < 0) { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.surface", /* tp_name */ - sizeof(ACIS_Entity_surface), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Entity_dealloc_surface, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS surface class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Entity_methods_surface, /* tp_methods */ - ACIS_Entity_members_surface, /* tp_members */ - ACIS_Entity_getseters_surface, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_surface, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Entity_new_surface, /* tp_new */ - }; - - -/* - * Python Module Definitions - */ - -// Module documentation can be accessible via __doc__ -const char *module_name = "Entity"; -const char *module_documentation = "Contains 3D ACIS Modeler entities, such as BODY, FACE, WIRE, etc."; + PyErr_SetString(PyExc_TypeError, "Problem with ENTITY type cheking"); + return false; + } + return retval != 0; +} -static PyModuleDef - ACIS_Entity_module = - { - PyModuleDef_HEAD_INIT, - module_name, - module_documentation, - -1, - NULL, NULL, NULL, NULL, NULL - }; - -PyMODINIT_FUNC -PyInit_Entity(void) -{ - // Create a Python module, ACIS.Topology - PyObject *m; - m = PyModule_Create(&ACIS_Entity_module); - if (m == NULL) - return NULL; +PyObject *_PyNew_BODY() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_BODY, NULL); +} - // Add ENTITY to the module - if (PyType_Ready(&ACIS_Entity_type_ENTITY) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_ENTITY); - PyModule_AddObject(m, "ENTITY", (PyObject *) &ACIS_Entity_type_ENTITY); +bool _PyCheck_BODY(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_BODY; +} - // Add BODY to the module - ACIS_Entity_type_BODY.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_BODY) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_BODY); - PyModule_AddObject(m, "BODY", (PyObject *) &ACIS_Entity_type_BODY); +PyObject *_PyNew_FACE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_FACE, NULL); +} - // Add FACE to the module - ACIS_Entity_type_FACE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_FACE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_FACE); - PyModule_AddObject(m, "FACE", (PyObject *) &ACIS_Entity_type_FACE); +bool _PyCheck_FACE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_FACE; +} - // Add EDGE to the module - ACIS_Entity_type_EDGE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_EDGE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_EDGE); - PyModule_AddObject(m, "EDGE", (PyObject *) &ACIS_Entity_type_EDGE); +PyObject *_PyNew_EDGE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_EDGE, NULL); +} - // Add WIRE to the module - ACIS_Entity_type_WIRE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_WIRE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_WIRE); - PyModule_AddObject(m, "WIRE", (PyObject *) &ACIS_Entity_type_WIRE); +bool _PyCheck_EDGE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_EDGE; +} - // Add LUMP to the module - ACIS_Entity_type_LUMP.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_LUMP) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_LUMP); - PyModule_AddObject(m, "LUMP", (PyObject *) &ACIS_Entity_type_LUMP); +PyObject *_PyNew_WIRE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_WIRE, NULL); +} - // Add SHELL to the module - ACIS_Entity_type_SHELL.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SHELL) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SHELL); - PyModule_AddObject(m, "SHELL", (PyObject *) &ACIS_Entity_type_SHELL); +bool _PyCheck_WIRE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_WIRE; +} - // Add SUBSHELL to the module - ACIS_Entity_type_SUBSHELL.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SUBSHELL) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SUBSHELL); - PyModule_AddObject(m, "SUBSHELL", (PyObject *) &ACIS_Entity_type_SUBSHELL); +PyObject *_PyNew_LUMP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_LUMP, NULL); +} - // Add COEDGE to the module - ACIS_Entity_type_COEDGE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_COEDGE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_COEDGE); - PyModule_AddObject(m, "COEDGE", (PyObject *) &ACIS_Entity_type_COEDGE); +bool _PyCheck_LUMP(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_LUMP; +} - // Add LOOP to the module - ACIS_Entity_type_LOOP.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_LOOP) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_LOOP); - PyModule_AddObject(m, "LOOP", (PyObject *) &ACIS_Entity_type_LOOP); +PyObject *_PyNew_SHELL() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SHELL, NULL); +} - // Add VERTEX to the module - ACIS_Entity_type_VERTEX.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_VERTEX) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_VERTEX); - PyModule_AddObject(m, "VERTEX", (PyObject *) &ACIS_Entity_type_VERTEX); +bool _PyCheck_SHELL(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SHELL; +} - // Add SURFACE to the module - ACIS_Entity_type_SURFACE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SURFACE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SURFACE); - PyModule_AddObject(m, "SURFACE", (PyObject *) &ACIS_Entity_type_SURFACE); +PyObject *_PyNew_SUBSHELL() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SUBSHELL, NULL); +} - // Add CONE to the module - ACIS_Entity_type_CONE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_CONE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_CONE); - PyModule_AddObject(m, "CONE", (PyObject *) &ACIS_Entity_type_CONE); +bool _PyCheck_SUBSHELL(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_SUBSHELL; +} - // Add PLANE to the module - ACIS_Entity_type_PLANE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_PLANE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_PLANE); - PyModule_AddObject(m, "PLANE", (PyObject *) &ACIS_Entity_type_PLANE); +PyObject *_PyNew_COEDGE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_COEDGE, NULL); +} - // Add SPHERE to the module - ACIS_Entity_type_SPHERE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SPHERE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SPHERE); - PyModule_AddObject(m, "SPHERE", (PyObject *) &ACIS_Entity_type_SPHERE); +bool _PyCheck_COEDGE(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_COEDGE; +} - // Add SPLINE to the module - ACIS_Entity_type_SPLINE.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_SPLINE) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_SPLINE); - PyModule_AddObject(m, "SPLINE", (PyObject *) &ACIS_Entity_type_SPLINE); +PyObject *_PyNew_LOOP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_LOOP, NULL); +} - // Add TORUS to the module - ACIS_Entity_type_TORUS.tp_base = &ACIS_Entity_type_ENTITY; - if (PyType_Ready(&ACIS_Entity_type_TORUS) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_TORUS); - PyModule_AddObject(m, "TORUS", (PyObject *) &ACIS_Entity_type_TORUS); +bool _PyCheck_LOOP(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_LOOP; +} - // Add surface to the module - if (PyType_Ready(&ACIS_Entity_type_surface) < 0) - return NULL; - Py_INCREF(&ACIS_Entity_type_surface); - PyModule_AddObject(m, "surface", (PyObject *) &ACIS_Entity_type_surface); +PyObject *_PyNew_VERTEX() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_VERTEX, NULL); +} - // Return the module and all included objects - return m; +bool _PyCheck_VERTEX(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_VERTEX; } -PyObject *_ACIS_new_ENTITY() +PyObject *_PyNew_SURFACE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_ENTITY, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SURFACE, NULL); } -bool _ACIS_check_ENTITY(PyObject *ob) +bool _PyCheck_SURFACE(PyObject *ob) { - int retval = PyObject_IsInstance(ob, (PyObject *) &ACIS_Entity_type_ENTITY); - if (retval < 0) - { - PyErr_SetString(PyExc_TypeError, "Problem with ENTITY type cheking"); - return false; - } - return retval != 0; + return Py_TYPE(ob) == &a3dp_type_SURFACE; } -PyObject *_ACIS_new_BODY() +PyObject *_PyNew_CONE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_BODY, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_CONE, NULL); } -bool _ACIS_check_BODY(PyObject *ob) +bool _PyCheck_CONE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_BODY; + return Py_TYPE(ob) == &a3dp_type_CONE; } -PyObject *_ACIS_new_FACE() +PyObject *_PyNew_PLANE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_FACE, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_PLANE, NULL); } -bool _ACIS_check_FACE(PyObject *ob) +bool _PyCheck_PLANE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_FACE; + return Py_TYPE(ob) == &a3dp_type_PLANE; } -PyObject *_ACIS_new_EDGE() +PyObject *_PyNew_SPHERE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_EDGE, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SPHERE, NULL); } -bool _ACIS_check_EDGE(PyObject *ob) +bool _PyCheck_SPHERE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_EDGE; + return Py_TYPE(ob) == &a3dp_type_SPHERE; } -PyObject *_ACIS_new_WIRE() +PyObject *_PyNew_SPLINE() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_WIRE, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SPLINE, NULL); } -bool _ACIS_check_WIRE(PyObject *ob) +bool _PyCheck_SPLINE(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_WIRE; + return Py_TYPE(ob) == &a3dp_type_SPLINE; } -PyObject *_ACIS_new_LUMP() +PyObject *_PyNew_TORUS() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_LUMP, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_TORUS, NULL); } -bool _ACIS_check_LUMP(PyObject *ob) +bool _PyCheck_TORUS(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_LUMP; + return Py_TYPE(ob) == &a3dp_type_TORUS; } -PyObject *_ACIS_new_SHELL() +PyObject *_PyNew_surface() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SHELL, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_surface, NULL); } -bool _ACIS_check_SHELL(PyObject *ob) +bool _PyCheck_surface(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_SHELL; + return Py_TYPE(ob) == &a3dp_type_surface; } -PyObject *_ACIS_new_SUBSHELL() +void _a3dp_make_null(PyObject *ob) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SUBSHELL, NULL); + if (_PyCheck_ENTITY(ob)) + { + ((a3dp_ENTITY *) ob)->_acis_obj = NULL; + } } -bool _ACIS_check_SUBSHELL(PyObject *ob) +void _a3dp_set_entity(PyObject *ob, ENTITY *ent) { - return Py_TYPE(ob) == &ACIS_Entity_type_SUBSHELL; + ((a3dp_ENTITY *)ob)->_acis_obj = ent; } -PyObject *_ACIS_new_COEDGE() +/** + * ENTITY_LIST class + */ + +void +a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_COEDGE, NULL); + // First, clear the contents of the ENTITY_LIST instance + self->_acis_obj->clear(); + + // Use ACIS_DELETE macro for ENTITY_LIST + ACIS_DELETE self->_acis_obj; + + // Delete the python object itself + Py_TYPE(self)->tp_free((PyObject *) self); } -bool _ACIS_check_COEDGE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - return Py_TYPE(ob) == &ACIS_Entity_type_COEDGE; + a3dp_ENTITY_LIST *self; + + self = (a3dp_ENTITY_LIST *) type->tp_alloc(type, 0); + if (self != NULL) + { + // Just getting rid of the dangling pointer + self->_acis_obj = NULL; + } + + return (PyObject *) self; } -PyObject *_ACIS_new_LOOP() +int +a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_LOOP, NULL); + // ENTITY_LIST takes no arguments, so parsing is necessary + self->_acis_obj = ACIS_NEW ENTITY_LIST(); + return 0; } -bool _ACIS_check_LOOP(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_LOOP; + self->_acis_obj->init(); + Py_RETURN_NONE; } -PyObject *_ACIS_new_VERTEX() +PyObject * +a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_VERTEX, NULL); + self->_acis_obj->clear(); + Py_RETURN_NONE; } -bool _ACIS_check_VERTEX(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg) { - return Py_TYPE(ob) == &ACIS_Entity_type_VERTEX; + // Treat arg as a borrowed reference + Py_INCREF(arg); + + int index = -1; + + if (!_PyCheck_ENTITY(arg)) + { + if (!_PyCheck_ENTITY_LIST(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY or ENTITY_LIST object"); + return NULL; + } + else + { + // This function returns void + self->_acis_obj->add(*((a3dp_ENTITY_LIST *) arg)->_acis_obj); + } + } + else + { + // This function returns the added ENTITY's index number + index = self->_acis_obj->add(((a3dp_ENTITY *) arg)->_acis_obj); + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + if (index != -1) + { + return PyLong_FromLong(index); + } + else + { + Py_RETURN_NONE; + } } -PyObject *_ACIS_new_SURFACE() +PyObject * +a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SURFACE, NULL); + // Treat arg as a borrowed reference + Py_INCREF(arg); + + int index = -1; + + if (!_PyCheck_ENTITY(arg)) + { + if (!_PyCheck_ENTITY_LIST(arg)) + { + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY, an ENTITY_LIST or an integer object"); + return NULL; + } + else + { + // This function returns the index number + index = self->_acis_obj->remove((int) PyLong_AsLong(arg)); + } + } + else + { + // This function returns void + self->_acis_obj->remove(*((a3dp_ENTITY_LIST *) arg)->_acis_obj); + } + } + else + { + // This function returns the removed ENTITY's index number + index = self->_acis_obj->remove(((a3dp_ENTITY *) arg)->_acis_obj); + } + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + if (index != -1) + { + return PyLong_FromLong(index); + } + else + { + Py_RETURN_NONE; + } } -bool _ACIS_check_SURFACE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_SURFACE; + return PyLong_FromLong(self->_acis_obj->count()); } -PyObject *_ACIS_new_CONE() +PyObject * +a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_CONE, NULL); + return PyLong_FromLong(self->_acis_obj->iteration_count()); } -bool _ACIS_check_CONE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_CONE; + self->_acis_obj->reverse(); + Py_RETURN_NONE; } -PyObject *_ACIS_new_PLANE() +PyObject * +a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_PLANE, NULL); + // Treat arg as a borrowed reference + Py_INCREF(arg); + + if (!_PyCheck_ENTITY(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY object"); + return NULL; + } + + int index = self->_acis_obj->lookup(((a3dp_ENTITY *) arg)->_acis_obj); + + // Treat arg as a borrowed reference + Py_DECREF(arg); + + // Prepare return values + return PyLong_FromLong(index); } -bool _ACIS_check_PLANE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_PLANE; + return PyLong_FromLong(self->_acis_obj->byte_count()); } -PyObject *_ACIS_new_SPHERE() +PyObject * +a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SPHERE, NULL); + ENTITY *_elem = self->_acis_obj->first(); + PyObject *retobj = __convert_entity(_elem); + return retobj; } -bool _ACIS_check_SPHERE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_SPHERE; + PyObject *retobj; + ENTITY *_elem = self->_acis_obj->next(); + + if (_elem) + { + retobj = __convert_entity(_elem); + } + else + { + // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + return retobj; } -PyObject *_ACIS_new_SPLINE() +PyObject * +a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_SPLINE, NULL); + if (!PyLong_Check(arg)) + { + PyErr_SetString(PyExc_TypeError, "Expecting an integer object"); + return NULL; + } + + Py_INCREF(arg); + int _from_index = (int) PyLong_AsLong(arg); + Py_DECREF(arg); + + PyObject *retobj; + ENTITY *_elem = self->_acis_obj->next_from(_from_index); + + if (_elem) + { + retobj = __convert_entity(_elem); + } + else + { + // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + + return retobj; } -bool _ACIS_check_SPLINE(PyObject *ob) +PyObject * +a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_SPLINE; + /* This function will create a Python generator/iterator */ + + // Reference increment is necessary, otherwise this ENTITY_LIST will be garbage collected + Py_INCREF(self); + + // Iterator/Generator creation functions always return self! + return (PyObject *) self; } -PyObject *_ACIS_new_TORUS() +PyObject * +a3dp_ENTITYLIST_iter(PyObject *self) { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_TORUS, NULL); + /* Must have the same signature as PyObject_GetIter() */ + + // Move the ENTITY_LIST pointer to the beginning + a3dp_ENTITYLIST__init((a3dp_ENTITY_LIST *) self); + + Py_INCREF(self); + return self; } -bool _ACIS_check_TORUS(PyObject *ob) +PyObject * +a3dp_ENTITYLIST_iter_next(PyObject *self) { - return Py_TYPE(ob) == &ACIS_Entity_type_TORUS; + /* Must have the same signature as PyIter_Next() */ + + // Convert the input argument to a ENTITY_LIST object + a3dp_ENTITY_LIST *_ent_list = (a3dp_ENTITY_LIST *) self; + + // Return the next element + return a3dp_ENTITYLIST__next(_ent_list); } -PyObject *_ACIS_new_surface() + +PyObject * +_PyNew_ENTITY_LIST() { - return PyObject_CallObject((PyObject *) &ACIS_Entity_type_surface, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_ENTITYLIST, NULL); } -bool _ACIS_check_surface(PyObject *ob) +bool +_PyCheck_ENTITY_LIST(PyObject *ob) { - return Py_TYPE(ob) == &ACIS_Entity_type_surface; + if (Py_TYPE(ob) == &a3dp_type_ENTITYLIST) + return true; + else + return false; } -void _ACIS_make_null(PyObject *ob) +PyObject * +__convert_entity(ENTITY *ent) { - if (_ACIS_check_ENTITY(ob)) + // Find the type name of the entity + const char *_type_name = ent->type_name(); + + // We could use a hashing function here... + PyObject *_retobj; + if (strcmp("body", _type_name) == 0) { - ((ACIS_Entity_ENTITY *) ob)->_acis_obj = NULL; + _retobj = _PyNew_BODY(); + _a3dp_set_entity(_retobj, ent); + } + else if (strcmp("face", _type_name) == 0) + { + _retobj = _PyNew_FACE(); + _a3dp_set_entity(_retobj, ent); + } + else if (strcmp("surface", _type_name) == 0) + { + _retobj = _PyNew_SURFACE(); + _a3dp_set_entity(_retobj, ent); } -} -void _ACIS_set_entity(PyObject *ob, ENTITY *ent) -{ - ((ACIS_Entity_ENTITY *)ob)->_acis_obj = ent; + return _retobj; } diff --git a/src/acis_entity.h b/src/acis_entity.h index 6e33c32..7743a66 100644 --- a/src/acis_entity.h +++ b/src/acis_entity.h @@ -9,24 +9,14 @@ * */ -#ifndef ACIS_ENTITY_H -#define ACIS_ENTITY_H +#ifndef A3DPY_ENTITY_H +#define A3DPY_ENTITY_H #include #include -#include "kernapi.hxx" -#include -#include -#include -#include -#include -#include -#include - -#include "acis_geometric_atoms.h" - -#include "acis_entity_export.h" +#include "acis_includes.h" +#include "acis_operators.h" #ifdef __cplusplus @@ -42,72 +32,55 @@ typedef struct ENTITY *_acis_obj; PyObject *attrib_name; PyObject *attrib_object_id; -} ACIS_Entity_ENTITY; - -int ACIS_ENTITY_EXPORT ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg); - -int ACIS_ENTITY_EXPORT ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self); - -void ACIS_ENTITY_EXPORT ACIS_Entity_dealloc_ENTITY(ACIS_Entity_ENTITY *self); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs); - -int ACIS_ENTITY_EXPORT ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwargs); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure); - -PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_type_name(PyObject *self); +} a3dp_ENTITY; + +int a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg); +int a3dp_ENTITY_clear(a3dp_ENTITY *self); +void a3dp_ENTITY_dealloc(a3dp_ENTITY *self); +PyObject *a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_ENTITY_repr(a3dp_ENTITY *self); +PyObject *a3dp_ENTITY_str(a3dp_ENTITY *self); +PyObject *a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); +int a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); +PyObject *a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); +int a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); +PyObject *a3dp_ENTITY_type_name(PyObject *self); static PyGetSetDef - ACIS_Entity_getseters_ENTITY[] = - { - { (char *) "name", (getter) ACIS_Entity_method_ENTITY_get_attrib_name, (setter) ACIS_Entity_method_ENTITY_set_attrib_name, (char *) "object name", NULL }, - { (char *) "id", (getter) ACIS_Entity_method_ENTITY_get_attrib_obj_id, (setter) ACIS_Entity_method_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Entity_members_ENTITY[] = + a3dp_getseters_ENTITY[] = { + { (char *) "name", (getter) a3dp_ENTITY_get_attrib_name, (setter) a3dp_ENTITY_set_attrib_name, (char *) "object name", NULL }, + { (char *) "id", (getter) a3dp_ENTITY_get_attrib_obj_id, (setter) a3dp_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, { NULL } /* Sentinel */ }; static PyMethodDef - ACIS_Entity_methods_ENTITY[] = + a3dp_methods_ENTITY[] = { - { "type_name", (PyCFunction) ACIS_Entity_method_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, + { "type_name", (PyCFunction) a3dp_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, { NULL } /* Sentinel */ }; static PyTypeObject - ACIS_Entity_type_ENTITY = + a3dp_type_ENTITY = { PyVarObject_HEAD_INIT(NULL, 0) "ACIS.ENTITY", /* tp_name */ - sizeof(ACIS_Entity_ENTITY), /* tp_basicsize */ + sizeof(a3dp_ENTITY), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor) ACIS_Entity_dealloc_ENTITY, /* tp_dealloc */ + (destructor) a3dp_ENTITY_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ - (reprfunc) ACIS_Entity_repr_ENTITY, /* tp_repr */ + (reprfunc) a3dp_ENTITY_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - (reprfunc) ACIS_Entity_str_ENTITY, /* tp_str */ + (reprfunc) a3dp_ENTITY_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -115,198 +88,1124 @@ static PyTypeObject Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ "ACIS ENTITY class", /* tp_doc */ - (traverseproc) ACIS_Entity_traverse_ENTITY, /* tp_traverse */ - (inquiry) ACIS_Entity_clear_ENTITY, /* tp_clear */ + (traverseproc) a3dp_ENTITY_traverse, /* tp_traverse */ + (inquiry) a3dp_ENTITY_clear, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - ACIS_Entity_methods_ENTITY, /* tp_methods */ - ACIS_Entity_members_ENTITY, /* tp_members */ - ACIS_Entity_getseters_ENTITY, /* tp_getset */ + a3dp_methods_ENTITY, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_ENTITY, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc) ACIS_Entity_init_ENTITY, /* tp_init */ + (initproc) a3dp_ENTITY_init, /* tp_init */ 0, /* tp_alloc */ - ACIS_Entity_new_ENTITY, /* tp_new */ + a3dp_ENTITY_new, /* tp_new */ }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_ENTITY(); +PyObject *_PyNew_ENTITY(); -bool ACIS_ENTITY_EXPORT _ACIS_check_ENTITY(PyObject *ob); +bool _PyCheck_ENTITY(PyObject *ob); // Define BODY typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_BODY; + a3dp_ENTITY base_obj; +} a3dp_BODY; + +int a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_BODY_repr(a3dp_BODY *self); +PyObject *a3dp_BODY_str(a3dp_BODY *self); + +static PyTypeObject + a3dp_type_BODY = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.BODY", /* tp_name */ + sizeof(a3dp_BODY), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_BODY_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_BODY_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS BODY class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_BODY_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_BODY(); -bool ACIS_ENTITY_EXPORT _ACIS_check_BODY(PyObject *ob); +PyObject *_PyNew_BODY(); + +bool _PyCheck_BODY(PyObject *ob); // Define FACE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_FACE; + a3dp_ENTITY base_obj; +} a3dp_FACE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_FACE(); +int a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_FACE_repr(a3dp_FACE *self); +PyObject *a3dp_FACE_str(a3dp_FACE *self); +PyObject *a3dp_FACE__sense(a3dp_FACE *self); +PyObject *a3dp_FACE__geometry(a3dp_FACE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_FACE(PyObject *ob); +static PyMethodDef + a3dp_methods_FACE[] = + { + { "sense", (PyCFunction) a3dp_FACE__sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, + { "geometry", (PyCFunction) a3dp_FACE__geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_FACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FACE", /* tp_name */ + sizeof(a3dp_FACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_FACE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_FACE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS FACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_FACE, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_FACE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_FACE(); + +bool _PyCheck_FACE(PyObject *ob); // Define EDGE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_EDGE; + a3dp_ENTITY base_obj; +} a3dp_EDGE; + +int a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_EDGE_repr(a3dp_EDGE *self); +PyObject *a3dp_EDGE_str(a3dp_EDGE *self); + +static PyTypeObject + a3dp_type_EDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.EDGE", /* tp_name */ + sizeof(a3dp_EDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_EDGE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_EDGE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS EDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_EDGE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_EDGE(); +PyObject *_PyNew_EDGE(); -bool ACIS_ENTITY_EXPORT _ACIS_check_EDGE(PyObject *ob); +bool _PyCheck_EDGE(PyObject *ob); // Define WIRE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_WIRE; + a3dp_ENTITY base_obj; +} a3dp_WIRE; + +int a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_WIRE_repr(a3dp_WIRE *self); +PyObject *a3dp_WIRE_str(a3dp_WIRE *self); + +static PyTypeObject + a3dp_type_WIRE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.WIRE", /* tp_name */ + sizeof(a3dp_WIRE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_WIRE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_WIRE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS WIRE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_WIRE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_WIRE(); +PyObject *_PyNew_WIRE(); -bool ACIS_ENTITY_EXPORT _ACIS_check_WIRE(PyObject *ob); +bool _PyCheck_WIRE(PyObject *ob); // Define LUMP typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_LUMP; + a3dp_ENTITY base_obj; +} a3dp_LUMP; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LUMP(); +int a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_LUMP_repr(a3dp_LUMP *self); +PyObject *a3dp_LUMP_str(a3dp_LUMP *self); + +static PyTypeObject + a3dp_type_LUMP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LUMP", /* tp_name */ + sizeof(a3dp_LUMP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_LUMP_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_LUMP_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LUMP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_LUMP_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -bool ACIS_ENTITY_EXPORT _ACIS_check_LUMP(PyObject *ob); + +PyObject *_PyNew_LUMP(); + +bool _PyCheck_LUMP(PyObject *ob); // Define SHELL typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SHELL; + a3dp_ENTITY base_obj; +} a3dp_SHELL; + +int a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SHELL_repr(a3dp_SHELL *self); +PyObject *a3dp_SHELL_str(a3dp_SHELL *self); + +static PyTypeObject + a3dp_type_SHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SHELL", /* tp_name */ + sizeof(a3dp_SHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SHELL_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SHELL_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SHELL_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SHELL(); +PyObject *_PyNew_SHELL(); -bool ACIS_ENTITY_EXPORT _ACIS_check_SHELL(PyObject *ob); +bool _PyCheck_SHELL(PyObject *ob); // Define SUBSHELL typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SUBSHELL; + a3dp_ENTITY base_obj; +} a3dp_SUBSHELL; + +int a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self); +PyObject *a3dp_SUBSHELL_str(a3dp_SUBSHELL *self); + +static PyTypeObject + a3dp_type_SUBSHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SUBSHELL", /* tp_name */ + sizeof(a3dp_SUBSHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SUBSHELL_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SUBSHELL_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SUBSHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SUBSHELL_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SUBSHELL(); +PyObject *_PyNew_SUBSHELL(); -bool ACIS_ENTITY_EXPORT _ACIS_check_SUBSHELL(PyObject *ob); +bool _PyCheck_SUBSHELL(PyObject *ob); // Define COEDGE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_COEDGE; + a3dp_ENTITY base_obj; +} a3dp_COEDGE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_COEDGE(); +int a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_COEDGE_repr(a3dp_COEDGE *self); +PyObject *a3dp_COEDGE_str(a3dp_COEDGE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_COEDGE(PyObject *ob); +static PyTypeObject + a3dp_type_COEDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.COEDGE", /* tp_name */ + sizeof(a3dp_COEDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_COEDGE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_COEDGE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS COEDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_COEDGE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_COEDGE(); + +bool _PyCheck_COEDGE(PyObject *ob); // Define LOOP typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_LOOP; + a3dp_ENTITY base_obj; +} a3dp_LOOP; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LOOP(); +int a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_LOOP_repr(a3dp_LOOP *self); +PyObject *a3dp_LOOP_str(a3dp_LOOP *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_LOOP(PyObject *ob); +static PyTypeObject + a3dp_type_LOOP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LOOP", /* tp_name */ + sizeof(a3dp_LOOP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_LOOP_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_LOOP_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LOOP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_LOOP_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_LOOP(); + +bool _PyCheck_LOOP(PyObject *ob); // Define VERTEX typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_VERTEX; + a3dp_ENTITY base_obj; +} a3dp_VERTEX; + +int a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_VERTEX_repr(a3dp_VERTEX *self); +PyObject *a3dp_VERTEX_str(a3dp_VERTEX *self); + +static PyTypeObject + a3dp_type_VERTEX = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.VERTEX", /* tp_name */ + sizeof(a3dp_VERTEX), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_VERTEX_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_VERTEX_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS VERTEX class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_VERTEX_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_VERTEX(); +PyObject *_PyNew_VERTEX(); -bool ACIS_ENTITY_EXPORT _ACIS_check_VERTEX(PyObject *ob); +bool _PyCheck_VERTEX(PyObject *ob); // Define SURFACE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SURFACE; + a3dp_ENTITY base_obj; +} a3dp_SURFACE; + +int a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SURFACE_repr(a3dp_SURFACE *self); +PyObject *a3dp_SURFACE_str(a3dp_SURFACE *self); +PyObject *a3dp_SURFACE__equation(a3dp_SURFACE *self); +PyObject *a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SURFACE(); +static PyMethodDef + a3dp_methods_SURFACE[] = + { + { "equation", (PyCFunction) a3dp_SURFACE__equation, METH_NOARGS, "Returns the equation of this SURFACE" }, + { "trans_surface", (PyCFunction) a3dp_SURFACE__trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, + { NULL } /* Sentinel */ + }; -bool ACIS_ENTITY_EXPORT _ACIS_check_SURFACE(PyObject *ob); +static PyTypeObject + a3dp_type_SURFACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SURFACE", /* tp_name */ + sizeof(a3dp_SURFACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SURFACE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SURFACE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SURFACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SURFACE, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SURFACE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SURFACE(); + +bool _PyCheck_SURFACE(PyObject *ob); // Define CONE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_CONE; + a3dp_ENTITY base_obj; +} a3dp_CONE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_CONE(); +int a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_CONE_repr(a3dp_CONE *self); +PyObject *a3dp_CONE_str(a3dp_CONE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_CONE(PyObject *ob); +static PyTypeObject + a3dp_type_CONE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.CONE", /* tp_name */ + sizeof(a3dp_CONE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_CONE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_CONE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS CONE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_CONE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_CONE(); + +bool _PyCheck_CONE(PyObject *ob); // Define PLANE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_PLANE; + a3dp_ENTITY base_obj; +} a3dp_PLANE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_PLANE(); +int a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_PLANE_repr(a3dp_PLANE *self); +PyObject *a3dp_PLANE_str(a3dp_PLANE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_PLANE(PyObject *ob); +static PyTypeObject + a3dp_type_PLANE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.PLANE", /* tp_name */ + sizeof(a3dp_PLANE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_PLANE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_PLANE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS PLANE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_PLANE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_PLANE(); + +bool _PyCheck_PLANE(PyObject *ob); // Define SPHERE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SPHERE; + a3dp_ENTITY base_obj; +} a3dp_SPHERE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPHERE(); +int a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPHERE_repr(a3dp_SPHERE *self); +PyObject *a3dp_SPHERE_str(a3dp_SPHERE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_SPHERE(PyObject *ob); +static PyTypeObject + a3dp_type_SPHERE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPHERE", /* tp_name */ + sizeof(a3dp_SPHERE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPHERE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPHERE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPHERE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPHERE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SPHERE(); + +bool _PyCheck_SPHERE(PyObject *ob); // Define SPLINE typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_SPLINE; + a3dp_ENTITY base_obj; +} a3dp_SPLINE; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPLINE(); +int a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_SPLINE_repr(a3dp_SPLINE *self); +PyObject *a3dp_SPLINE_str(a3dp_SPLINE *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_SPLINE(PyObject *ob); +static PyTypeObject + a3dp_type_SPLINE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPLINE", /* tp_name */ + sizeof(a3dp_SPLINE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPLINE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPLINE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPLINE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPLINE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + +PyObject *_PyNew_SPLINE(); + +bool _PyCheck_SPLINE(PyObject *ob); // Define TORUS typedef struct { - ACIS_Entity_ENTITY base_obj; -} ACIS_Entity_TORUS; + a3dp_ENTITY base_obj; +} a3dp_TORUS; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_TORUS(); +int a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_TORUS_repr(a3dp_TORUS *self); +PyObject *a3dp_TORUS_str(a3dp_TORUS *self); -bool ACIS_ENTITY_EXPORT _ACIS_check_TORUS(PyObject *ob); +static PyTypeObject + a3dp_type_TORUS = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.TORUS", /* tp_name */ + sizeof(a3dp_TORUS), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_TORUS_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_TORUS_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS TORUS class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_TORUS_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_TORUS(); + +bool _PyCheck_TORUS(PyObject *ob); // Define surface typedef struct { surface* _acis_obj; -} ACIS_Entity_surface; +} a3dp_surface; -PyObject ACIS_ENTITY_EXPORT *_ACIS_new_surface(); +void a3dp_surface_dealloc(a3dp_surface *self); +PyObject *a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg); +PyObject *a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg); -bool ACIS_ENTITY_EXPORT _ACIS_check_surface(PyObject *ob); +static PyMethodDef + a3dp_methods_surface[] = + { + { "eval_normal", (PyCFunction) a3dp_surface__eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, + { "eval_position", (PyCFunction) a3dp_surface__eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_surface = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.surface", /* tp_name */ + sizeof(a3dp_surface), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_surface_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS surface class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_surface, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_surface_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_surface_new, /* tp_new */ + }; + +PyObject *_PyNew_surface(); + +bool _PyCheck_surface(PyObject *ob); + +// Define ENTITY_LIST +typedef struct +{ + PyObject_HEAD + ENTITY_LIST *_acis_obj; +} a3dp_ENTITY_LIST; + +void a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); +int a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg); +PyObject *a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self); +PyObject *a3dp_ENTITYLIST_iter(PyObject *self); +PyObject *a3dp_ENTITYLIST_iter_next(PyObject *self); + +static PyMethodDef + a3dp_methods_ENTITY_LIST[] = + { + { "add", (PyCFunction) a3dp_ENTITYLIST__add, METH_O, "Adds an entity or entities to the list" }, + { "remove", (PyCFunction) a3dp_ENTITYLIST__remove, METH_O, "Removes an entity or entities from the list" }, + { "count", (PyCFunction) a3dp_ENTITYLIST__count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, + { "iteration_count", (PyCFunction) a3dp_ENTITYLIST__iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, + { "init", (PyCFunction) a3dp_ENTITYLIST__init, METH_NOARGS, "Adds an entity or entities to the list" }, + { "clear", (PyCFunction) a3dp_ENTITYLIST__clear, METH_NOARGS, "Clear all entries from the list and reset indexes and counters for reuse" }, + { "lookup", (PyCFunction) a3dp_ENTITYLIST__lookup, METH_O, "Adds an entity or entities to the list" }, + { "reverse", (PyCFunction) a3dp_ENTITYLIST__reverse, METH_NOARGS, "Adds an entity or entities to the list" }, + { "byte_count", (PyCFunction) a3dp_ENTITYLIST__byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, + { "first", (PyCFunction) a3dp_ENTITYLIST__first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, + { "next", (PyCFunction) a3dp_ENTITYLIST__next, METH_NOARGS, "Returns the next undeleted (live) entry" }, + { "next_from", (PyCFunction) a3dp_ENTITYLIST__next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, + { "array", (PyCFunction) a3dp_ENTITYLIST__array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, + { NULL } /* Sentinel */ + }; + +static PyTypeObject + a3dp_type_ENTITYLIST = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.ENTITY_LIST", /* tp_name */ + sizeof(a3dp_ENTITY_LIST), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_ENTITYLIST_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS ENTITY_LIST class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc) a3dp_ENTITYLIST_iter, /* tp_iter */ + (iternextfunc) a3dp_ENTITYLIST_iter_next, /* tp_iternext */ + a3dp_methods_ENTITY_LIST, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_ENTITYLIST_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_ENTITYLIST_new, /* tp_new */ + }; + +PyObject *_PyNew_ENTITY_LIST(); + +bool _PyCheck_ENTITY_LIST(PyObject *ob); + +PyObject *__convert_entity(ENTITY *ent); // Additional functions @@ -315,12 +1214,12 @@ bool ACIS_ENTITY_EXPORT _ACIS_check_surface(PyObject *ob); * Sets the internal ocis_obj variable to NULL * @param ob Topology object, such as ENTITY, BODY, FACE, etc. */ -void ACIS_ENTITY_EXPORT _ACIS_make_null(PyObject *ob); +void _a3dp_make_null(PyObject *ob); -void ACIS_ENTITY_EXPORT _ACIS_set_entity(PyObject *ob, ENTITY *ent); +void _a3dp_set_entity(PyObject *ob, ENTITY *ent); #ifdef __cplusplus } #endif -#endif // !ACIS_ENTITY_H +#endif // !A3DPY_ENTITY_H diff --git a/src/acis_enums.cpp b/src/acis_enums.cpp new file mode 100644 index 0000000..bdb4100 --- /dev/null +++ b/src/acis_enums.cpp @@ -0,0 +1,22 @@ +#include "acis_enums.h" + + +PyObject *_PyNew_NDBOOL_KEEP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_NDBOOLKEEP, NULL); +} + +bool _PyCheck_NDBOOL_KEEP(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_NDBOOLKEEP; +} + +PyObject *_PyNew_sweep_bool_type() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_sweepbooltype, NULL); +} + +bool _PyCheck_sweep_bool_type(PyObject *ob) +{ + return Py_TYPE(ob) == &a3dp_type_sweepbooltype; +} diff --git a/src/acis_enums.h b/src/acis_enums.h new file mode 100644 index 0000000..695ac49 --- /dev/null +++ b/src/acis_enums.h @@ -0,0 +1,102 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_ENUMS_H +#define A3DPY_ENUMS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Define NDBOOL_KEEP enum +typedef struct { + PyObject_HEAD +} a3dp_NDBOOL_KEEP; + +/** + * NDBOOL_KEEP enum + */ + +static PyTypeObject + a3dp_type_NDBOOLKEEP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.NDBOOL_KEEP", /* tp_name */ + sizeof(a3dp_NDBOOL_KEEP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ + }; + +PyObject *_PyNew_NDBOOL_KEEP(); +bool _PyCheck_NDBOOL_KEEP(PyObject *ob); + +// Define sweep_bool_type enum +typedef struct { + PyObject_HEAD +} a3dp_sweep_bool_type; + +/** + * sweep_bool_type enum + */ + +static PyTypeObject + a3dp_type_sweepbooltype = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_bool_type", /* tp_name */ + sizeof(a3dp_sweep_bool_type), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "Sweep to body boolean operation type", /* tp_doc */ + }; + +PyObject *_PyNew_sweep_bool_type(); +bool _PyCheck_sweep_bool_type(PyObject *ob); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_ENUMS_H diff --git a/src/acis_geometric_atoms.cpp b/src/acis_geometric_atoms.cpp deleted file mode 100644 index 042a9ce..0000000 --- a/src/acis_geometric_atoms.cpp +++ /dev/null @@ -1,2778 +0,0 @@ -#include "acis_geometric_atoms.h" - - -/** - * SPAposition wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAposition(ACIS_GeometricAtoms_SPAposition *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAposition(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAposition *self; - - self = (ACIS_GeometricAtoms_SPAposition *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAposition(ACIS_GeometricAtoms_SPAposition *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAposition(input_x, input_y, input_z); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPAposition(ACIS_GeometricAtoms_SPAposition *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAposition object (%s, %s, %s)", _x, _y, _z); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_coordinate(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->coordinate(_i)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_coordinate(ACIS_GeometricAtoms_SPAposition *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - static char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAposition class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The coordinate input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_coordinate(_i, _new_c); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_x(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_y(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_set_z(ACIS_GeometricAtoms_SPAposition *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_x(ACIS_GeometricAtoms_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_y(ACIS_GeometricAtoms_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_z(ACIS_GeometricAtoms_SPAposition *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_x_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAposition_x(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_y_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAposition_y(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAposition_z_getter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAposition_z(self); -} - -static int -ACIS_GeometricAtoms_method_SPAposition_x_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAposition_set_x(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAposition_y_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAposition_set_y(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAposition_z_setter(ACIS_GeometricAtoms_SPAposition *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAposition_set_z(self, value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAposition[] = - { - { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAposition_x_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, - { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAposition_y_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, - { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAposition_z_getter, (setter) ACIS_GeometricAtoms_method_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAposition[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAposition[] = - { - { "coordinate", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_coordinate, METH_O, "Returns the i-th component value" }, - { "set_coordinate", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, - { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the x-coordinate value" }, - { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the y-coordinate value" }, - { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_set_x, METH_O, "Sets the z-coordinate value" }, - { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_x, METH_NOARGS, "Returns the x-coordinate value" }, - { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_y, METH_NOARGS, "Returns the y-coordinate value" }, - { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAposition_z, METH_NOARGS, "Returns the z-coordinate value" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAposition = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAposition", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAposition), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAposition, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAposition, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAposition, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAposition, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAposition, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAposition, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAposition, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAposition, /* tp_new */ - }; - - -/** - * SPAvector wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAvector(ACIS_GeometricAtoms_SPAvector *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAvector(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAvector *self; - - self = (ACIS_GeometricAtoms_SPAvector *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAvector(ACIS_GeometricAtoms_SPAvector *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAvector(input_x, input_y, input_z); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPAvector(ACIS_GeometricAtoms_SPAvector *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAvector object (%s, %s, %s)", _x, _y, _z); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_component(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->component(_i)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_component(ACIS_GeometricAtoms_SPAvector *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - static char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAvector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_component(_i, _new_c); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_x(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_y(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_set_z(ACIS_GeometricAtoms_SPAvector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_x(ACIS_GeometricAtoms_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_y(ACIS_GeometricAtoms_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_z(ACIS_GeometricAtoms_SPAvector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_x_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAvector_x(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_y_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAvector_y(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAvector_z_getter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAvector_z(self); -} - -static int -ACIS_GeometricAtoms_method_SPAvector_x_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAvector_set_x(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAvector_y_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAvector_set_y(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAvector_z_setter(ACIS_GeometricAtoms_SPAvector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAvector_set_z(self, value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAvector[] = - { - { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAvector_x_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAvector_y_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAvector_z_getter, (setter) ACIS_GeometricAtoms_method_SPAvector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAvector[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAvector[] = - { - { "component", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAvector_z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAvector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAvector", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAvector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAvector, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAvector, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAvector, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAvector, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAvector, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAvector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAvector, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAvector, /* tp_new */ - }; - - -/** - * SPAunit_vector wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAunit_vector(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAunit_vector *self; - - self = (ACIS_GeometricAtoms_SPAunit_vector *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *args, PyObject *kwargs) -{ - double input_x = 0.0, input_y = 0.0, input_z = 0.0; - - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ddd", kwlist, &input_x, &input_y, &input_z)) - return -1; - - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAunit_vector(input_x, input_y, input_z); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPAunit_vector(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); - - char *_x = PyOS_double_to_string(x, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_x) - return PyErr_NoMemory(); - - char *_y = PyOS_double_to_string(y, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_y) - return PyErr_NoMemory(); - - char *_z = PyOS_double_to_string(z, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_z) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPAunit_vector object (%s, %s, %s)", _x, _y, _z); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_component(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - // No parsing required as this function takes exactly 1 argument - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - int _i = (int) PyLong_AsLong(arg); - - // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The input argument must be 0, 1 or 2"); - return NULL; - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Return data from the ACIS object - return PyFloat_FromDouble(self->_acis_obj->component(_i)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_component(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *args, PyObject *kwargs) -{ - int _i; - double _new_c; - - static char *kwlist[] = - { - (char *) "i", - (char *) "new_c", - NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id", kwlist, &_i, &_new_c)) - return NULL; - - // SPAunit_vector class has a coord field which has a size of 3, corresponding to x, y, z - if (_i < 0 || _i > 2) - { - PyErr_SetString(PyExc_ValueError, "The component input must be 0, 1 or 2"); - return NULL; - } - - self->_acis_obj->set_component(_i, _new_c); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_x(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_x(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_y(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_y(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_set_z(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - double _value; - - // No parsing required as this function takes exactly 1 argument - if (PyFloat_Check(arg)) - { - _value = PyFloat_AsDouble(arg); - } - else - { - if (PyLong_Check(arg)) - { - _value = PyLong_AsDouble(arg); - } - else - { - PyErr_SetString(PyExc_TypeError, "The input argument must be a floating point number"); - return NULL; - } - } - - self->_acis_obj->set_z(_value); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_x(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->x()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_y(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->y()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_z(ACIS_GeometricAtoms_SPAunit_vector *self) -{ - return PyFloat_FromDouble(self->_acis_obj->z()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_x_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAunit_vector_x(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_y_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAunit_vector_y(self); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAunit_vector_z_getter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - return ACIS_GeometricAtoms_method_SPAunit_vector_z(self); -} - -static int -ACIS_GeometricAtoms_method_SPAunit_vector_x_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAunit_vector_set_x(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAunit_vector_y_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAunit_vector_set_y(self, value); - return 0; -} - -static int -ACIS_GeometricAtoms_method_SPAunit_vector_z_setter(ACIS_GeometricAtoms_SPAunit_vector *self, PyObject *value, void *closure) -{ - ACIS_GeometricAtoms_method_SPAunit_vector_set_z(self, value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAunit_vector[] = - { - { (char *) "x_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_x_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_y_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) ACIS_GeometricAtoms_method_SPAunit_vector_z_getter, (setter) ACIS_GeometricAtoms_method_SPAunit_vector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAunit_vector[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAunit_vector[] = - { - { "component", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) ACIS_GeometricAtoms_method_SPAunit_vector_z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAunit_vector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAunit_vector", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAunit_vector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAunit_vector, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAunit_vector, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPAunit_vector, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAunit_vector, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAunit_vector, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAunit_vector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAunit_vector, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAunit_vector, /* tp_new */ - }; - - -/** - * SPAmatrix wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAmatrix(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAmatrix(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAmatrix *self; - - self = (ACIS_GeometricAtoms_SPAmatrix *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAmatrix(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAmatrix(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_column(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *arg) -{ - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - // Create a new SPAvector python object - PyObject *_python_ret = _ACIS_new_SPAvector(); - - // Convert python input argument into a C variable - int _in_col = (int) PyLong_AsLong(arg); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->column(_in_col); - - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_row(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *arg) -{ - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "The input argument must be an integer"); - return NULL; - } - - // Create a new SPAvector python object - PyObject *_python_ret = _ACIS_new_SPAvector(); - - // Convert python input argument into a C variable - int _in_row = (int) PyLong_AsLong(arg); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAvector *) _python_ret)->_acis_obj = self->_acis_obj->row(_in_row); - - // Treat the input argument as a borrowed reference - Py_INCREF(arg); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_inverse(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Create a new SPAmatrix python object - PyObject *_python_ret = _ACIS_new_SPAmatrix(); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->inverse(); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_transpose(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Create a new SPAmatrix python object - PyObject *_python_ret = _ACIS_new_SPAmatrix(); - - // Execute the ACIS function and set ACIS variable inside the new python object - *((ACIS_GeometricAtoms_SPAmatrix *) _python_ret)->_acis_obj = self->_acis_obj->transpose(); - - // Return the updated python object - return _python_ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_determinant(ACIS_GeometricAtoms_SPAmatrix *self) -{ - // Execute the ACIS function and return the value as a python object - return PyFloat_FromDouble(self->_acis_obj->determinant()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_element(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - int input_row, input_col; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "row", - (char *) "col", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_row, &input_col)) - return NULL; - - // Execute the ACIS function and return the value as a python object - return PyFloat_FromDouble(self->_acis_obj->element(input_row, input_col)); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_set_element(ACIS_GeometricAtoms_SPAmatrix *self, PyObject *args, PyObject *kwargs) -{ - int input_row, input_col; - double input_new_e; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "row", - (char *) "col", - (char *) "new_e", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iid", kwlist, &input_row, &input_col, &input_new_e)) - return NULL; - - // Execute the ACIS function - self->_acis_obj->set_element(input_row, input_col, input_new_e); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAmatrix_is_identity(ACIS_GeometricAtoms_SPAmatrix *self) -{ - logical _ret_val = self->_acis_obj->is_identity(); - - if (_ret_val) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAmatrix[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAmatrix[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAmatrix[] = - { - { "column", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_column, METH_O, "Extracts a column from this matrix" }, - { "row", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_row, METH_O, "Extracts a row from this matrix" }, - { "element", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, - { "set_element", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, - { "determinant", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_determinant, METH_NOARGS, "Returns the determinant of this matrix" }, - { "transpose", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_transpose, METH_NOARGS, "Returns a transpose of this matrix" }, - { "inverse", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_inverse, METH_NOARGS, "Returns the inverse of this matrix" }, - { "is_identity", (PyCFunction) ACIS_GeometricAtoms_method_SPAmatrix_is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAmatrix = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAmatrix", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAmatrix), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAmatrix, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAmatrix, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAmatrix, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAmatrix, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAmatrix, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAmatrix, /* tp_new */ - }; - - -/** - * SPAtransf wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPAtransf(ACIS_GeometricAtoms_SPAtransf *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPAtransf(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPAtransf *self; - - self = (ACIS_GeometricAtoms_SPAtransf *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPAtransf(ACIS_GeometricAtoms_SPAtransf *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPAtransf(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_affine(ACIS_GeometricAtoms_SPAtransf *self) -{ - PyObject *_ret = _ACIS_new_SPAmatrix(); - - *((ACIS_GeometricAtoms_SPAmatrix *) _ret)->_acis_obj = self->_acis_obj->affine(); - - return _ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_inverse(ACIS_GeometricAtoms_SPAtransf *self) -{ - PyObject *_ret = _ACIS_new_SPAtransf(); - - *((ACIS_GeometricAtoms_SPAtransf *) _ret)->_acis_obj = self->_acis_obj->inverse(); - - return _ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_translation(ACIS_GeometricAtoms_SPAtransf *self) -{ - PyObject *_ret = _ACIS_new_SPAvector(); - - *((ACIS_GeometricAtoms_SPAvector *) _ret)->_acis_obj = self->_acis_obj->translation(); - - return _ret; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_identity(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->identity(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_reflect(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->reflect(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_rotate(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->rotate(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_scaling(ACIS_GeometricAtoms_SPAtransf *self) -{ - return PyFloat_FromDouble(self->_acis_obj->scaling()); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPAtransf_shear(ACIS_GeometricAtoms_SPAtransf *self) -{ - logical _check = self->_acis_obj->shear(); - - if (_check) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPAtransf[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPAtransf[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPAtransf[] = - { - { "affine", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_affine, METH_NOARGS, "Returns the affine portion of the transformation" }, - { "inverse", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_inverse, METH_NOARGS, "Returns the inverse transformation" }, - { "translation", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, - { "identity", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, - { "reflect", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, - { "rotate", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, - { "scaling", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, - { "shear", (PyCFunction) ACIS_GeometricAtoms_method_SPAtransf_shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPAtransf = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPAtransf), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPAtransf, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAtransf represents a general 3D affine transformation", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPAtransf, /* tp_methods */ - ACIS_GeometricAtoms_members_SPAtransf, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPAtransf, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPAtransf, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPAtransf, /* tp_new */ - }; - - -/** - * SPApar_pos wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPApar_pos(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPApar_pos *self; - - self = (ACIS_GeometricAtoms_SPApar_pos *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPApar_pos(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPApar_pos(ACIS_GeometricAtoms_SPApar_pos *self) -{ - double u = self->_acis_obj->u; double v = self->_acis_obj->v; - - char *_u = PyOS_double_to_string(u, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_u) - return PyErr_NoMemory(); - - char *_v = PyOS_double_to_string(v, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_v) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPApar_pos object (%s, %s)", _u, _v); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_pos_u_getter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->u); -} - -static int -ACIS_GeometricAtoms_method_SPApar_pos_u_setter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - self->_acis_obj->u = PyFloat_AsDouble(value); - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_pos_v_getter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->v); -} - -static int -ACIS_GeometricAtoms_method_SPApar_pos_v_setter(ACIS_GeometricAtoms_SPApar_pos *self, PyObject *value, void *closure) -{ - self->_acis_obj->v = PyFloat_AsDouble(value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPApar_pos[] = - { - { (char *) "u", (getter) ACIS_GeometricAtoms_method_SPApar_pos_u_getter, (setter) ACIS_GeometricAtoms_method_SPApar_pos_u_setter, (char *) "value of the u parameter", NULL }, - { (char *) "v", (getter) ACIS_GeometricAtoms_method_SPApar_pos_v_getter, (setter) ACIS_GeometricAtoms_method_SPApar_pos_v_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPApar_pos[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPApar_pos[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPApar_pos = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPApar_pos), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPApar_pos, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_pos, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_pos, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPApar_pos, /* tp_methods */ - ACIS_GeometricAtoms_members_SPApar_pos, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPApar_pos, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPApar_pos, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPApar_pos, /* tp_new */ - }; - - -/** - * SPApar_vec wrapper - */ - -static void -ACIS_GeometricAtoms_dealloc_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_GeometricAtoms_new_SPApar_vec(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_GeometricAtoms_SPApar_vec *self; - - self = (ACIS_GeometricAtoms_SPApar_vec *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_GeometricAtoms_init_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW SPApar_vec(); - - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_repr_SPApar_vec(ACIS_GeometricAtoms_SPApar_vec *self) -{ - double du = self->_acis_obj->du; double dv = self->_acis_obj->dv; - - char *_du = PyOS_double_to_string(du, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_du) - return PyErr_NoMemory(); - - char *_dv = PyOS_double_to_string(dv, 'r', 0, Py_DTSF_ADD_DOT_0, NULL); - if (!_dv) - return PyErr_NoMemory(); - - return PyUnicode_FromFormat("SPApar_vec object (%s, %s)", _du, _dv); -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_vec_du_getter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->du); -} - -static int -ACIS_GeometricAtoms_method_SPApar_vec_du_setter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - self->_acis_obj->du = PyFloat_AsDouble(value); - return 0; -} - -static PyObject * -ACIS_GeometricAtoms_method_SPApar_vec_dv_getter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - return PyFloat_FromDouble(self->_acis_obj->dv); -} - -static int -ACIS_GeometricAtoms_method_SPApar_vec_dv_setter(ACIS_GeometricAtoms_SPApar_vec *self, PyObject *value, void *closure) -{ - self->_acis_obj->dv = PyFloat_AsDouble(value); - return 0; -} - -static PyGetSetDef - ACIS_GeometricAtoms_getseters_SPApar_vec[] = - { - { (char *) "du", (getter) ACIS_GeometricAtoms_method_SPApar_vec_du_getter, (setter) ACIS_GeometricAtoms_method_SPApar_vec_du_setter, (char *) "value of the u parameter", NULL }, - { (char *) "dv", (getter) ACIS_GeometricAtoms_method_SPApar_vec_dv_getter, (setter) ACIS_GeometricAtoms_method_SPApar_vec_dv_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_GeometricAtoms_members_SPApar_vec[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_GeometricAtoms_methods_SPApar_vec[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_GeometricAtoms_type_SPApar_vec = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(ACIS_GeometricAtoms_SPApar_vec), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_GeometricAtoms_dealloc_SPApar_vec, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_vec, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) ACIS_GeometricAtoms_repr_SPApar_vec, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_GeometricAtoms_methods_SPApar_vec, /* tp_methods */ - ACIS_GeometricAtoms_members_SPApar_vec, /* tp_members */ - ACIS_GeometricAtoms_getseters_SPApar_vec, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_GeometricAtoms_init_SPApar_vec, /* tp_init */ - 0, /* tp_alloc */ - ACIS_GeometricAtoms_new_SPApar_vec, /* tp_new */ - }; - -/** - * Python module definitions - */ - -static PyObject * -ACIS_GeometricAtoms_method_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_origin = NULL, *input_x_axis = NULL, *input_y_axis = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "new_origin", - (char *) "new_x_axis", - (char *) "new_y_axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_origin, &input_x_axis, &input_y_axis)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAposition(input_origin)) - { - PyErr_SetString(PyExc_TypeError, "First parameter (new_origin) must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_SPAunit_vector(input_x_axis)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (new_x_axis) must be a SPAunit_vector object"); - return NULL; - } - - if (!_ACIS_check_SPAunit_vector(input_y_axis)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (new_y_axis) must be a SPAunit_vector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAposition *&_new_origin = ((ACIS_GeometricAtoms_SPAposition *) input_origin)->_acis_obj; - SPAunit_vector *&_new_x_axis = ((ACIS_GeometricAtoms_SPAunit_vector *) input_x_axis)->_acis_obj; - SPAunit_vector *&_new_y_axis = ((ACIS_GeometricAtoms_SPAunit_vector *) input_y_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = coordinate_transf(*_new_origin, *_new_x_axis, *_new_y_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_make_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_affine = NULL, *input_translation = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "affine", - (char *) "translation", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_affine, &input_translation)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAmatrix(input_affine)) - { - PyErr_SetString(PyExc_TypeError, "First parameter (affine) must be a SPAmatrix object"); - return NULL; - } - - if (!_ACIS_check_SPAvector(input_translation)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (translate) must be a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAmatrix *&_affine = ((ACIS_GeometricAtoms_SPAmatrix *) input_affine)->_acis_obj; - SPAvector *&_translation = ((ACIS_GeometricAtoms_SPAvector *) input_translation)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = make_transf(*_affine, *_translation); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_axis = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_axis)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAvector(input_axis)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_axis = ((ACIS_GeometricAtoms_SPAvector *) input_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = reflect_transf(*_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_axis = NULL; - double input_angle; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "angle", - (char *) "axis", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dO", kwlist, &input_angle, &input_axis)) - return NULL; - - // Check inputs - if (!_ACIS_check_SPAvector(input_axis)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_axis = ((ACIS_GeometricAtoms_SPAvector *) input_axis)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = rotate_transf(input_angle, *_axis); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL, *input_arg6 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "scale", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOOO", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5, &input_arg6)) - return NULL; - - SPAtransf retval; - - if (!PyFloat_Check(input_arg1)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg1 = PyFloat_AsDouble(input_arg1); - - if (input_arg2 != NULL || input_arg3 != NULL) - { - if (!PyFloat_Check(input_arg2) && !PyFloat_Check(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg2 = PyFloat_AsDouble(input_arg2); - double _arg3 = PyFloat_AsDouble(input_arg3); - - if (input_arg4 != NULL || input_arg5 != NULL || input_arg6 != NULL) - { - if (!PyFloat_Check(input_arg4) && !PyFloat_Check(input_arg5) && !PyFloat_Check(input_arg5)) - { - PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); - return NULL; - } - - double _arg4 = PyFloat_AsDouble(input_arg4); - double _arg5 = PyFloat_AsDouble(input_arg5); - double _arg6 = PyFloat_AsDouble(input_arg5); - - retval = scale_transf(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6); - } - else - { - retval = scale_transf(_arg1, _arg2, _arg3); - } - } - else - { - retval = scale_transf(_arg1); - } - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double _shear_xy, _shear_xz, _shear_yz; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "shearxy", - (char *) "shearxz", - (char *) "shearyz", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddd", kwlist, &_shear_xy, &_shear_xz, &_shear_yz)) - return NULL; - - // Execute ACIS function - SPAtransf retval = shear_transf(_shear_xy, _shear_xz, _shear_yz); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_disp = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "disp", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_disp)) - return NULL; - - // "disp" must be a SPAvector object - if (!_ACIS_check_SPAvector(input_disp)) - { - PyErr_SetString(PyExc_TypeError, "Expecting SPAvector object"); - return NULL; - } - - // Get the ACIS object from the user input - SPAvector *&_disp = ((ACIS_GeometricAtoms_SPAvector *) input_disp)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = translate_transf(*_disp); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_GeometricAtoms_method_angle_between(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL, *input_z = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "z", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist, &input_v1, &input_v2, &input_z)) - return NULL; - - // Set return value - double _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - if (input_z != NULL) - { - if (!_ACIS_check_SPAvector(input_z)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_z = ((ACIS_GeometricAtoms_SPAunit_vector *) input_z)->_acis_obj; - - _retval = angle_between(*_v1, *_v2, *_z); - } - else - { - _retval = angle_between(*_v1, *_v2); - } - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_z != NULL) - { - if (!_ACIS_check_SPAunit_vector(input_z)) - { - PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_z = ((ACIS_GeometricAtoms_SPAunit_vector *) input_z)->_acis_obj; - - _retval = angle_between(*_v1, *_v2, *_z); - } - else - { - _retval = angle_between(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return PyFloat object - return PyFloat_FromDouble(_retval); -} - -static PyObject * -ACIS_GeometricAtoms_method_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - double input_res = -1.0; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "res", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2) || !_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = antiparallel(*_v1, *_v2, input_res); - } - else - { - _retval = antiparallel(*_v1, *_v2); - } - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2) || !_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector or SPAvector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = antiparallel(*_v1, *_v2, input_res); - } - else - { - _retval = antiparallel(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - int input_same_dir = 0; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "same_dir", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i", kwlist, &input_v1, &input_v2, &input_same_dir)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - _retval = are_parallel(*_v1, *_v2, input_same_dir); - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - _retval = are_parallel(*_v1, *_v2, input_same_dir); - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_v1, &input_v2)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - _retval = are_perpendicular(*_v1, *_v2); - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - _retval = are_perpendicular(*_v1, *_v2); - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_biparallel(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_v1 = NULL, *input_v2 = NULL; - double input_res = -1.0; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "v1", - (char *) "v2", - (char *) "res", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) - return NULL; - - // Set return value - logical _retval; - - // SPAvector scenario - if (_ACIS_check_SPAvector(input_v1)) - { - if (!_ACIS_check_SPAvector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); - return NULL; - } - - SPAvector *&_v1 = ((ACIS_GeometricAtoms_SPAvector *) input_v1)->_acis_obj; - SPAvector *&_v2 = ((ACIS_GeometricAtoms_SPAvector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = biparallel(*_v1, *_v2, input_res); - } - else - { - _retval = biparallel(*_v1, *_v2); - } - } - else if (_ACIS_check_SPAunit_vector(input_v1)) - { - // SPAunit_vector scenario - if (!_ACIS_check_SPAunit_vector(input_v2)) - { - PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); - return NULL; - } - - SPAunit_vector *&_v1 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v1)->_acis_obj; - SPAunit_vector *&_v2 = ((ACIS_GeometricAtoms_SPAunit_vector *) input_v2)->_acis_obj; - - if (input_res >= 0.0) - { - _retval = biparallel(*_v1, *_v2, input_res); - } - else - { - _retval = biparallel(*_v1, *_v2); - } - } - else - { - PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); - return NULL; - } - - // Return logical - if (_retval == 1) - Py_RETURN_TRUE; - Py_RETURN_FALSE; -} - -static PyObject * -ACIS_GeometricAtoms_method_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_ang; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ang", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) - return NULL; - - double _retval = degrees_to_radians(input_ang); - - // Return double - return PyFloat_FromDouble(_retval); -} - -static PyObject * -ACIS_GeometricAtoms_method_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_ang; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ang", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) - return NULL; - - double _retval = radians_to_degrees(input_ang); - - // Return double - return PyFloat_FromDouble(_retval); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resabs(PyObject *self) -{ - return PyFloat_FromDouble(get_resabs()); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resfit(PyObject *self) -{ - return PyFloat_FromDouble(get_resfit()); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resmch(PyObject *self) -{ - return PyFloat_FromDouble(get_resmch()); -} - -static PyObject * -ACIS_GeometricAtoms_method_get_resnor(PyObject *self) -{ - return PyFloat_FromDouble(get_resnor()); -} - -static PyObject * -ACIS_GeometricAtoms_method_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) - return NULL; - - if (!_ACIS_check_SPAposition(input_pt1) || !_ACIS_check_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); - return NULL; - } - - SPAposition *&_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; - SPAposition *&_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; - - // Return double - return PyFloat_FromDouble(distance_to_point(*_pt1, *_pt2)); -} - -static PyObject * -ACIS_GeometricAtoms_method_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) - return NULL; - - if (!_ACIS_check_SPAposition(input_pt1) || !_ACIS_check_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); - return NULL; - } - - SPAposition *&_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; - SPAposition *&_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; - - // Return double - return PyFloat_FromDouble(distance_to_point_squared(*_pt1, *_pt2)); -} - -static PyMethodDef - module_methods[] = - { - { "coordinate_transf", (PyCFunction) ACIS_GeometricAtoms_method_coordinate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a coordinate transformation" }, - { "make_transf", (PyCFunction) ACIS_GeometricAtoms_method_make_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation retrieving the needed information from the provided transformation matrix and the scaling vector" }, - { "reflect_transf", (PyCFunction) ACIS_GeometricAtoms_method_reflect_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a reflection through a plane, specified by its normal" }, - { "rotate_transf", (PyCFunction) ACIS_GeometricAtoms_method_rotate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a simple rotation by an angle about a given axis" }, - { "scale_transf", (PyCFunction) ACIS_GeometricAtoms_method_scale_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a scale transformation (uniform, non-uniform and shear)" }, - { "shear_transf", (PyCFunction) ACIS_GeometricAtoms_method_shear_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a shear transformation" }, - { "translate_transf", (PyCFunction) ACIS_GeometricAtoms_method_translate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a translation by a given vector" }, - { "angle_between", (PyCFunction) ACIS_GeometricAtoms_method_angle_between, METH_VARARGS | METH_KEYWORDS, "Calculates the angle between two vectors or unit vectors" }, - { "antiparallel", (PyCFunction) ACIS_GeometricAtoms_method_antiparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are anti-parallel" }, - { "are_parallel", (PyCFunction) ACIS_GeometricAtoms_method_are_parallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are parallel" }, - { "are_perpendicular", (PyCFunction) ACIS_GeometricAtoms_method_are_perpendicular, METH_VARARGS | METH_KEYWORDS, " Determines if two vectors or unit vectors are perpendicular" }, - { "biparallel", (PyCFunction) ACIS_GeometricAtoms_method_biparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are bi-parallel" }, - { "degrees_to_radians", (PyCFunction) ACIS_GeometricAtoms_method_degrees_to_radians, METH_VARARGS | METH_KEYWORDS, "Converts an angle from degrees to radians" }, - { "radians_to_degrees", (PyCFunction) ACIS_GeometricAtoms_method_radians_to_degrees, METH_VARARGS | METH_KEYWORDS, "Converts an angle from radians to degrees" }, - { "get_resabs", (PyCFunction) ACIS_GeometricAtoms_method_get_resabs, METH_NOARGS, "Gets the SPAresabs resolution" }, - { "get_resfit", (PyCFunction) ACIS_GeometricAtoms_method_get_resfit, METH_NOARGS, "Gets the SPAresfit resolution" }, - { "get_resmch", (PyCFunction) ACIS_GeometricAtoms_method_get_resmch, METH_NOARGS, "Gets the resmch resolution" }, - { "get_resnor", (PyCFunction) ACIS_GeometricAtoms_method_get_resnor, METH_NOARGS, "Gets the SPAresnor resolution" }, - { "distance_to_point", (PyCFunction) ACIS_GeometricAtoms_method_distance_to_point, METH_VARARGS | METH_KEYWORDS, "Determines the distance between two points" }, - { "distance_to_point_squared", (PyCFunction) ACIS_GeometricAtoms_method_distance_to_point_squared, METH_VARARGS | METH_KEYWORDS, "\tComputes the squared distance between two positions" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "GeometricAtoms"; -const char *module_documentation = "Contains 3D ACIS Modeler geometric atoms, e.g. SPAposition, SPApar_pos, etc."; - -static struct PyModuleDef - ACIS_GeometricAtoms_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_GeometricAtoms(void) -{ - PyObject *m; - m = PyModule_Create(&ACIS_GeometricAtoms_module); - if (m == NULL) - return NULL; - - // SPAposition - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAposition) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAposition); - PyModule_AddObject(m, "SPAposition", (PyObject *) &ACIS_GeometricAtoms_type_SPAposition); - - // SPAtransf - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAtransf) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAtransf); - PyModule_AddObject(m, "SPAtransf", (PyObject *) &ACIS_GeometricAtoms_type_SPAtransf); - - // SPAmatrix - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAmatrix) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAmatrix); - PyModule_AddObject(m, "SPAmatrix", (PyObject *) &ACIS_GeometricAtoms_type_SPAmatrix); - - // SPAvector - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAvector) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAvector); - PyModule_AddObject(m, "SPAvector", (PyObject *) &ACIS_GeometricAtoms_type_SPAvector); - - // SPAunit_vector - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPAunit_vector) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPAunit_vector); - PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &ACIS_GeometricAtoms_type_SPAunit_vector); - - // SPApar_pos - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPApar_pos) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPApar_pos); - PyModule_AddObject(m, "SPApar_pos", (PyObject *) &ACIS_GeometricAtoms_type_SPApar_pos); - - // SPApar_vec - if (PyType_Ready(&ACIS_GeometricAtoms_type_SPApar_vec) < 0) - return NULL; - Py_INCREF(&ACIS_GeometricAtoms_type_SPApar_vec); - PyModule_AddObject(m, "SPApar_vec", (PyObject *) &ACIS_GeometricAtoms_type_SPApar_vec); - - return m; -} - -bool _ACIS_check_SPAposition(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAposition; -} - -PyObject *_ACIS_new_SPAposition() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAposition, NULL); -} - -bool _ACIS_check_SPAvector(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAvector; -} - -PyObject *_ACIS_new_SPAvector() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAvector, NULL); -} - -bool _ACIS_check_SPAunit_vector(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAunit_vector; -} - -PyObject *_ACIS_new_SPAunit_vector() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAunit_vector, NULL); -} - -bool _ACIS_check_SPAmatrix(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAmatrix; -} - -PyObject *_ACIS_new_SPAmatrix() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAmatrix, NULL); -} - -bool _ACIS_check_SPAtransf(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPAtransf; -} - -PyObject *_ACIS_new_SPAtransf() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPAtransf, NULL); -} - -bool _ACIS_check_SPApar_pos(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPApar_pos; -} - -PyObject *_ACIS_new_SPApar_pos() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPApar_pos, NULL); -} - -bool _ACIS_check_SPApar_vec(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_GeometricAtoms_type_SPApar_vec; -} - -PyObject *_ACIS_new_SPApar_vec() -{ - return PyObject_CallObject((PyObject *) &ACIS_GeometricAtoms_type_SPApar_vec, NULL); -} diff --git a/src/acis_geometric_atoms.h b/src/acis_geometric_atoms.h deleted file mode 100644 index ce4ef8a..0000000 --- a/src/acis_geometric_atoms.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_GEOMETRIC_ATOMS_H -#define ACIS_GEOMETRIC_ATOMS_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "acis_geometric_atoms_export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Define SPAposition -typedef struct -{ - PyObject_HEAD - SPAposition *_acis_obj; -} ACIS_GeometricAtoms_SPAposition; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAposition(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAposition(PyObject *ob); - -// Define SPAvector -typedef struct -{ - PyObject_HEAD - SPAvector *_acis_obj; -} ACIS_GeometricAtoms_SPAvector; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAvector(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAvector(PyObject *ob); - -// Define SPAunit_vector -typedef struct -{ - PyObject_HEAD - SPAunit_vector *_acis_obj; -} ACIS_GeometricAtoms_SPAunit_vector; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAunit_vector(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAunit_vector(PyObject *ob); - -// Define SPAmatrix -typedef struct -{ - PyObject_HEAD - SPAmatrix *_acis_obj; -} ACIS_GeometricAtoms_SPAmatrix; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAmatrix(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAmatrix(PyObject *ob); - -// Define SPAtransf -typedef struct -{ - PyObject_HEAD - SPAtransf *_acis_obj; -} ACIS_GeometricAtoms_SPAtransf; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPAtransf(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPAtransf(PyObject *ob); - -// Define SPApar_pos -typedef struct -{ - PyObject_HEAD - SPApar_pos *_acis_obj; -} ACIS_GeometricAtoms_SPApar_pos; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPApar_pos(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPApar_pos(PyObject *ob); - -// Define SPApar_vec -typedef struct -{ - PyObject_HEAD - SPApar_vec *_acis_obj; -} ACIS_GeometricAtoms_SPApar_vec; - -PyObject ACIS_GEOMETRIC_ATOMS_EXPORT *_ACIS_new_SPApar_vec(); - -bool ACIS_GEOMETRIC_ATOMS_EXPORT _ACIS_check_SPApar_vec(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_GEOMETRIC_ATOMS_H diff --git a/src/acis_includes.h b/src/acis_includes.h new file mode 100644 index 0000000..f986116 --- /dev/null +++ b/src/acis_includes.h @@ -0,0 +1,36 @@ +#ifndef A3DPY_INCLUDES_H +#define A3DPY_INCLUDES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif // !A3DPY_INCLUDES_H diff --git a/src/acis_licensing.cpp b/src/acis_licensing.cpp deleted file mode 100644 index 486d06f..0000000 --- a/src/acis_licensing.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include - -#include -#include -#include - - -static PyObject * -ACIS_spa_unlock_products(PyObject *self, PyObject *arg) -{ - // Check if the input is a string - if (!PyUnicode_Check(arg)) - { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } - - // Convert PyObject to C-style string - const char *unlock_str = PyUnicode_AsUTF8(arg); - - // Call ACIS Licensing API - spa_unlock_result out = spa_unlock_products(unlock_str); - - // If license is good, then return True. Otherwise, return the licensing error message - if (SPA_UNLOCK_PASS == out.get_state()) - Py_RETURN_TRUE; - else - return PyUnicode_FromString(out.get_message_text()); -} - -static PyMethodDef - ACIS_Licensing_methods[] = - { - { "spa_unlock_products", (PyCFunction) ACIS_spa_unlock_products, METH_O, "Unlock the 3D ACIS Modeler using the license key" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_documentation = "Contains 3D ACIS Modeler licensing API related functions and classes"; - -static struct PyModuleDef - ACIS_Licensing_module = - { - PyModuleDef_HEAD_INIT, - "Licensing", // name of module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - ACIS_Licensing_methods - }; - -PyMODINIT_FUNC -PyInit_Licensing(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Licensing_module); - if (m == NULL) - return NULL; - - return m; -} diff --git a/src/acis_lists.cpp b/src/acis_lists.cpp deleted file mode 100644 index 7166971..0000000 --- a/src/acis_lists.cpp +++ /dev/null @@ -1,440 +0,0 @@ -#include "acis_lists.h" - - -/** - * 3D ACIS Modeler - ENTITY_LIST wrapper - */ - -static void -ACIS_Lists_dealloc_ENTITY_LIST(ACIS_Lists_ENTITY_LIST *self) -{ - // First, clear the contents of the ENTITY_LIST instance - self->_acis_obj->clear(); - - // Use ACIS_DELETE macro for ENTITY_LIST - ACIS_DELETE self->_acis_obj; - - // Delete the python object itself - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_Lists_new_ENTITY_LIST(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_Lists_ENTITY_LIST *self; - - self = (ACIS_Lists_ENTITY_LIST *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_Lists_init_ENTITY_LIST(ACIS_Lists_ENTITY_LIST *self) -{ - // ENTITY_LIST takes no arguments, so parsing is necessary - self->_acis_obj = ACIS_NEW ENTITY_LIST(); - return 0; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_init(ACIS_Lists_ENTITY_LIST *self) -{ - self->_acis_obj->init(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_clear(ACIS_Lists_ENTITY_LIST *self) -{ - self->_acis_obj->clear(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_add(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - int index = -1; - - if (!_ACIS_check_ENTITY(arg)) - { - if (!_ACIS_check_ENTITY_LIST(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY or ENTITY_LIST object"); - return NULL; - } - else - { - // This function returns void - self->_acis_obj->add(*((ACIS_Lists_ENTITY_LIST *) arg)->_acis_obj); - } - } - else - { - // This function returns the added ENTITY's index number - index = self->_acis_obj->add(((ACIS_Entity_ENTITY *) arg)->_acis_obj); - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - if (index != -1) - { - return PyLong_FromLong(index); - } - else - { - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_remove(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - int index = -1; - - if (!_ACIS_check_ENTITY(arg)) - { - if (!_ACIS_check_ENTITY_LIST(arg)) - { - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY, an ENTITY_LIST or an integer object"); - return NULL; - } - else - { - // This function returns the index number - index = self->_acis_obj->remove((int) PyLong_AsLong(arg)); - } - } - else - { - // This function returns void - self->_acis_obj->remove(*((ACIS_Lists_ENTITY_LIST *) arg)->_acis_obj); - } - } - else - { - // This function returns the removed ENTITY's index number - index = self->_acis_obj->remove(((ACIS_Entity_ENTITY *) arg)->_acis_obj); - } - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - if (index != -1) - { - return PyLong_FromLong(index); - } - else - { - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_count(ACIS_Lists_ENTITY_LIST *self) -{ - return PyLong_FromLong(self->_acis_obj->count()); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_iteration_count(ACIS_Lists_ENTITY_LIST *self) -{ - return PyLong_FromLong(self->_acis_obj->iteration_count()); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_reverse(ACIS_Lists_ENTITY_LIST *self) -{ - self->_acis_obj->reverse(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_lookup(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - // Treat arg as a borrowed reference - Py_INCREF(arg); - - if (!_ACIS_check_ENTITY(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an ENTITY object"); - return NULL; - } - - int index = self->_acis_obj->lookup(((ACIS_Entity_ENTITY *) arg)->_acis_obj); - - // Treat arg as a borrowed reference - Py_DECREF(arg); - - // Prepare return values - return PyLong_FromLong(index); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_byte_count(ACIS_Lists_ENTITY_LIST *self) -{ - return PyLong_FromLong(self->_acis_obj->byte_count()); -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_first(ACIS_Lists_ENTITY_LIST *self) -{ - ENTITY *_elem = self->_acis_obj->first(); - PyObject *retobj = __convert_entity(_elem); - return retobj; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_next(ACIS_Lists_ENTITY_LIST *self) -{ - PyObject *retobj; - ENTITY *_elem = self->_acis_obj->next(); - - if (_elem) - { - retobj = __convert_entity(_elem); - } - else - { - // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - - return retobj; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_next_from(ACIS_Lists_ENTITY_LIST *self, PyObject *arg) -{ - if (!PyLong_Check(arg)) - { - PyErr_SetString(PyExc_TypeError, "Expecting an integer object"); - return NULL; - } - - Py_INCREF(arg); - int _from_index = (int) PyLong_AsLong(arg); - Py_DECREF(arg); - - PyObject *retobj; - ENTITY *_elem = self->_acis_obj->next_from(_from_index); - - if (_elem) - { - retobj = __convert_entity(_elem); - } - else - { - // This is a requirement for iterator/generator to stop. Otherwise, you will observe an infinite loop. - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - - return retobj; -} - -static PyObject * -ACIS_Lists_method_ENTITY_LIST_array(ACIS_Lists_ENTITY_LIST *self) -{ - /* This function will create a Python generator/iterator */ - - // Reference increment is necessary, otherwise this ENTITY_LIST will be garbage collected - Py_INCREF(self); - - // Iterator/Generator creation functions always return self! - return (PyObject *) self; -} - -static PyObject * -ACIS_Lists_iter_ENTITY_LIST(PyObject *self) -{ - /* Must have the same signature as PyObject_GetIter() */ - - // Move the ENTITY_LIST pointer to the beginning - ACIS_Lists_method_ENTITY_LIST_init((ACIS_Lists_ENTITY_LIST *) self); - - Py_INCREF(self); - return self; -} - -static PyObject * -ACIS_Lists_iter_next_ENTITY_LIST(PyObject *self) -{ - /* Must have the same signature as PyIter_Next() */ - - // Convert the input argument to a ENTITY_LIST object - ACIS_Lists_ENTITY_LIST *_ent_list = (ACIS_Lists_ENTITY_LIST *) self; - - // Return the next element - return ACIS_Lists_method_ENTITY_LIST_next(_ent_list); -} - -static PyGetSetDef - ACIS_Lists_getseters_ENTITY_LIST[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Lists_members_ENTITY_LIST[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Lists_methods_ENTITY_LIST[] = - { - { "add", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_add, METH_O, "Adds an entity or entities to the list" }, - { "remove", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_remove, METH_O, "Removes an entity or entities from the list" }, - { "count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, - { "iteration_count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, - { "init", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_init, METH_NOARGS, "Adds an entity or entities to the list" }, - { "lookup", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_lookup, METH_O, "Adds an entity or entities to the list" }, - { "reverse", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_reverse, METH_NOARGS, "Adds an entity or entities to the list" }, - { "byte_count", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, - { "first", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, - { "next", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_next, METH_NOARGS, "Returns the next undeleted (live) entry" }, - { "next_from", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, - { "array", (PyCFunction) ACIS_Lists_method_ENTITY_LIST_array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Lists_type_ENTITY_LIST = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.ENTITY_LIST", /* tp_name */ - sizeof(ACIS_Lists_ENTITY_LIST), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Lists_dealloc_ENTITY_LIST, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS ENTITY_LIST class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) ACIS_Lists_iter_ENTITY_LIST, /* tp_iter */ - (iternextfunc) ACIS_Lists_iter_next_ENTITY_LIST, /* tp_iternext */ - ACIS_Lists_methods_ENTITY_LIST, /* tp_methods */ - ACIS_Lists_members_ENTITY_LIST, /* tp_members */ - ACIS_Lists_getseters_ENTITY_LIST, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Lists_init_ENTITY_LIST, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Lists_new_ENTITY_LIST, /* tp_new */ - }; - - -/* - * Python Module Definitions - */ - -// Module documentation can be accessible via __doc__ -const char *module_name = "Lists"; -const char *module_documentation = "Contains 3D ACIS Modeler lists and containers, such as ENTITY_LIST"; - -static PyModuleDef - ACIS_Lists_module = - { - PyModuleDef_HEAD_INIT, - module_name, - module_documentation, - -1, - NULL, NULL, NULL, NULL, NULL - }; - -PyMODINIT_FUNC -PyInit_Lists(void) -{ - // Create a Python module, ACIS.Objects - PyObject *m; - m = PyModule_Create(&ACIS_Lists_module); - if (m == NULL) - return NULL; - - // Initialize ACIS ENTITY_LIST class as a Python type - if (PyType_Ready(&ACIS_Lists_type_ENTITY_LIST) < 0) - return NULL; - - // Increase the reference counter of the ENTITY_LIST type - Py_INCREF(&ACIS_Lists_type_ENTITY_LIST); - - // Add ENTITY_LIST type to the Objects module - PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &ACIS_Lists_type_ENTITY_LIST); - - // Return the module and all included objects - return m; -} - -PyObject *_ACIS_new_ENTITY_LIST() -{ - return PyObject_CallObject((PyObject *) &ACIS_Lists_type_ENTITY_LIST, NULL); -} - -bool _ACIS_check_ENTITY_LIST(PyObject *ob) -{ - if (Py_TYPE(ob) == &ACIS_Lists_type_ENTITY_LIST) - return true; - else - return false; -} - -PyObject *__convert_entity(ENTITY *ent) -{ - // Find the type name of the entity - const char *_type_name = ent->type_name(); - - // We could use a hashing function here... - PyObject *_retobj; - if (strcmp("body", _type_name) == 0) - { - _retobj = _ACIS_new_BODY(); - _ACIS_set_entity(_retobj, ent); - } - else if (strcmp("face", _type_name) == 0) - { - _retobj = _ACIS_new_FACE(); - _ACIS_set_entity(_retobj, ent); - } - else if (strcmp("surface", _type_name) == 0) - { - _retobj = _ACIS_new_SURFACE(); - _ACIS_set_entity(_retobj, ent); - } - - return _retobj; -} diff --git a/src/acis_lists.h b/src/acis_lists.h deleted file mode 100644 index 1838e70..0000000 --- a/src/acis_lists.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_LISTS_H -#define ACIS_LISTS_H - -#include -#include - -#include - -#include "acis_entity.h" - -#include "acis_lists_export.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -// Define ENTITY_LIST -typedef struct -{ - PyObject_HEAD - ENTITY_LIST *_acis_obj; -} ACIS_Lists_ENTITY_LIST; - -PyObject ACIS_LISTS_EXPORT *_ACIS_new_ENTITY_LIST(); - -bool ACIS_LISTS_EXPORT _ACIS_check_ENTITY_LIST(PyObject *ob); - -PyObject ACIS_LISTS_EXPORT *__convert_entity(ENTITY *ent); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_LISTS_H diff --git a/src/acis_modeler.cpp b/src/acis_modeler.cpp index a93f873..3d3d0f0 100644 --- a/src/acis_modeler.cpp +++ b/src/acis_modeler.cpp @@ -1,705 +1,313 @@ #include "acis_modeler.h" -bool disabled_acis_freelisting = false; - -static PyObject * -ACIS_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_n = 0; - int input_freelisting = 1; +const char *module_name = "Modeler"; +const char *module_documentation = "3D ACIS Modeler"; - // List of keyword arguments that this function can take - static char *kwlist[] = +static PyMethodDef + module_methods[] = { - (char *) "n", - (char *) "freelisting", - NULL + { "spa_unlock_products", (PyCFunction) a3dp_spa_unlock_products, METH_O, "Unlock the 3D ACIS Modeler using the license key" }, + { "api_start_modeller", (PyCFunction) a3dp_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Starts the 3D ACIS Modeler" }, + { "api_stop_modeller", (PyCFunction) a3dp_api_stop_modeller, METH_NOARGS, "Stops the 3D ACIS Modeler" }, + { "is_modeler_started", (PyCFunction) a3dp_is_modeler_started, METH_NOARGS, "Checks if the 3D ACIS Modeler started" }, + { "api_start_modeler", (PyCFunction) a3dp_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Alternative way to call api_start_modeller()" }, + { "api_stop_modeler", (PyCFunction) a3dp_api_stop_modeller, METH_NOARGS, "Alternative way to call api_stop_modeller()" }, + { "api_save_entity_list", (PyCFunction) a3dp_api_save_entity_list, METH_VARARGS | METH_KEYWORDS, "Writes entities to a file in text or binary format" }, + { "api_set_file_info", (PyCFunction) a3dp_api_set_file_info, METH_VARARGS | METH_KEYWORDS, "Sets required header info to be written to ACIS save files" }, + { "api_get_file_info", (PyCFunction) a3dp_api_get_file_info, METH_O | METH_KEYWORDS, "Gets header info from the last restored file" }, + { "api_save_version", (PyCFunction) a3dp_api_save_version, METH_VARARGS | METH_KEYWORDS, "Sets the save file format" }, + { "api_set_dbl_option", (PyCFunction) a3dp_api_set_dbl_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given double" }, + { "api_set_int_option", (PyCFunction) a3dp_api_set_int_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given integer" }, + { "api_set_str_option", (PyCFunction) a3dp_api_set_str_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given string" }, + { "api_solid_block", (PyCFunction) a3dp_api_solid_block, METH_VARARGS | METH_KEYWORDS, "Creates a solid block given two positions on a diagonal of the block" }, + { "api_make_cuboid", (PyCFunction) a3dp_api_make_cuboid, METH_VARARGS | METH_KEYWORDS, "Creates cuboid of given width (x), depth (y) and height (z)" }, + { "api_make_frustum", (PyCFunction) a3dp_api_make_frustum, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical cone or cylinder of given height and radii" }, + { "api_make_prism", (PyCFunction) a3dp_api_make_prism, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical prism of given height, radii, and number of sides" }, + { "api_make_pyramid", (PyCFunction) a3dp_api_make_pyramid, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical pyramid of given height, radii, and number of sides" }, + { "api_make_sphere", (PyCFunction) a3dp_api_make_sphere, METH_VARARGS | METH_KEYWORDS, "Creates a sphere of given radius, centered at the origin" }, + { "api_make_torus", (PyCFunction) a3dp_api_make_torus, METH_VARARGS | METH_KEYWORDS, "Creates a torus of given major and minor radii centered at the origin" }, + { "api_apply_transf", (PyCFunction) a3dp_api_apply_transf, METH_VARARGS | METH_KEYWORDS, "Changes the transform entity attached to a body" }, + { "api_remove_transf", (PyCFunction) a3dp_api_remove_transf, METH_VARARGS | METH_KEYWORDS, "Removes (discards) the transformation of a body" }, + { "api_sheet_from_ff", (PyCFunction) a3dp_api_sheet_from_ff, METH_VARARGS | METH_KEYWORDS, "Creates a sheet body as a copy of a face" }, + { "api_unite", (PyCFunction) a3dp_api_unite, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean unite operation" }, + { "api_intersect", (PyCFunction) a3dp_api_intersect, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean intersect operation on two bodies" }, + { "api_subtract", (PyCFunction) a3dp_api_subtract, METH_VARARGS | METH_KEYWORDS, "Executes a Boolean subtract operation" }, + { "api_imprint", (PyCFunction) a3dp_api_imprint, METH_VARARGS | METH_KEYWORDS, "Intersects two bodies and imprints the intersection graph on both bodies" }, + { "api_boolean_chop_body", (PyCFunction) a3dp_api_boolean_chop_body, METH_VARARGS | METH_KEYWORDS, "Executes simultaneous Boolean intersect and subtract operations on two bodies" }, + { "api_make_sweep_path", (PyCFunction) a3dp_api_make_sweep_path, METH_VARARGS | METH_KEYWORDS, "Constructs a path useful for creating a swept surface" }, + { "api_sweep_with_options", (PyCFunction) a3dp_api_sweep_with_options, METH_VARARGS | METH_KEYWORDS, "Sweeps the given profile along an edge, a distance, a vector or an axis" }, + { "get_owner_transf", (PyCFunction) a3dp_get_owner_transf, METH_VARARGS | METH_KEYWORDS, "Gets a copy of the SPAtransf from the owner of an ENTITY" }, + { "api_get_faces", (PyCFunction) a3dp_api_get_faces, METH_VARARGS | METH_KEYWORDS, "Gets all faces related to an entity" }, + { "api_get_edges", (PyCFunction) a3dp_api_get_edges, METH_VARARGS | METH_KEYWORDS, "Gets all the edges related to an entity" }, + { "coordinate_transf", (PyCFunction) a3dp_coordinate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a coordinate transformation" }, + { "make_transf", (PyCFunction) a3dp_make_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation retrieving the needed information from the provided transformation matrix and the scaling vector" }, + { "reflect_transf", (PyCFunction) a3dp_reflect_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a reflection through a plane, specified by its normal" }, + { "rotate_transf", (PyCFunction) a3dp_rotate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a simple rotation by an angle about a given axis" }, + { "scale_transf", (PyCFunction) a3dp_scale_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a scale transformation (uniform, non-uniform and shear)" }, + { "shear_transf", (PyCFunction) a3dp_shear_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a shear transformation" }, + { "translate_transf", (PyCFunction) a3dp_translate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a translation by a given vector" }, + { "angle_between", (PyCFunction) a3dp_angle_between, METH_VARARGS | METH_KEYWORDS, "Calculates the angle between two vectors or unit vectors" }, + { "antiparallel", (PyCFunction) a3dp_antiparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are anti-parallel" }, + { "are_parallel", (PyCFunction) a3dp_are_parallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are parallel" }, + { "are_perpendicular", (PyCFunction) a3dp_are_perpendicular, METH_VARARGS | METH_KEYWORDS, " Determines if two vectors or unit vectors are perpendicular" }, + { "biparallel", (PyCFunction) a3dp_biparallel, METH_VARARGS | METH_KEYWORDS, "Determines if two vectors or unit vectors are bi-parallel" }, + { "degrees_to_radians", (PyCFunction) a3dp_degrees_to_radians, METH_VARARGS | METH_KEYWORDS, "Converts an angle from degrees to radians" }, + { "radians_to_degrees", (PyCFunction) a3dp_radians_to_degrees, METH_VARARGS | METH_KEYWORDS, "Converts an angle from radians to degrees" }, + { "get_resabs", (PyCFunction) a3dp_get_resabs, METH_NOARGS, "Gets the SPAresabs resolution" }, + { "get_resfit", (PyCFunction) a3dp_get_resfit, METH_NOARGS, "Gets the SPAresfit resolution" }, + { "get_resmch", (PyCFunction) a3dp_get_resmch, METH_NOARGS, "Gets the resmch resolution" }, + { "get_resnor", (PyCFunction) a3dp_get_resnor, METH_NOARGS, "Gets the SPAresnor resolution" }, + { "distance_to_point", (PyCFunction) a3dp_distance_to_point, METH_VARARGS | METH_KEYWORDS, "Determines the distance between two points" }, + { "distance_to_point_squared", (PyCFunction) a3dp_distance_to_point_squared, METH_VARARGS | METH_KEYWORDS, "\tComputes the squared distance between two positions" }, + { NULL, NULL, 0, NULL } }; - // Try to parse input arguments and/or keywords - // api_start_modeller does not utilize the "n" argument, but following the implementation but make it optional - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist, &input_n, &input_freelisting)) - return NULL; - - // Disable ACIS freelisting facility if freelisting=False - if (!input_freelisting) +struct PyModuleDef + a3dp_module = { - // Display a warning message - PyErr_WarnEx(PyExc_Warning, "Disabling ACIS freelisting...", 0); - // Disable ACIS freelisting - base_configuration base_config; - base_config.enable_freelists = FALSE; - base_config.raw_allocator = malloc; - base_config.raw_destructor = free; - initialize_base(&base_config); - // Set the global variable for terminate_nase - disabled_acis_freelisting = true; - } - - // Call ACIS API and check outcome - outcome result; - result = api_start_modeller(input_n); - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} + PyModuleDef_HEAD_INIT, + module_name, // name of the module + module_documentation, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + module_methods + }; -static PyObject * -ACIS_api_stop_modeller(PyObject *self) +PyMODINIT_FUNC +PyInit_Modeler(void) { - // Call ACIS API and check outcome - outcome result; - result = api_stop_modeller(); - - // If ACIS freelisting disabled, we need to call terminate_base() - if (disabled_acis_freelisting) - { - // Display a warning message - PyErr_WarnEx(PyExc_Warning, "Terminating ACIS...", 0); - terminate_base(); - } + PyObject *m; - // Check outcome - if (!check_outcome(result)) + m = PyModule_Create(&a3dp_module); + if (m == NULL) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_is_modeler_started(PyObject *self) -{ - // Initialize variables - logical check_modeler; - - // Call ACIS API - check_modeler = is_modeler_started(); - - // Return Python value - if (check_modeler) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} -static PyObject * -ACIS_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - double input_value; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sd", kwlist, &input_name, &input_value)) + // SPAposition + if (PyType_Ready(&a3dp_type_SPAposition) < 0) return NULL; + Py_INCREF(&a3dp_type_SPAposition); + PyModule_AddObject(m, "SPAposition", (PyObject *) &a3dp_type_SPAposition); - API_BEGIN - - result = api_set_dbl_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) + // SPAtransf + if (PyType_Ready(&a3dp_type_SPAtransf) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - int input_value; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; + Py_INCREF(&a3dp_type_SPAtransf); + PyModule_AddObject(m, "SPAtransf", (PyObject *) &a3dp_type_SPAtransf); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si", kwlist, &input_name, &input_value)) + // SPAmatrix + if (PyType_Ready(&a3dp_type_SPAmatrix) < 0) return NULL; + Py_INCREF(&a3dp_type_SPAmatrix); + PyModule_AddObject(m, "SPAmatrix", (PyObject *) &a3dp_type_SPAmatrix); - API_BEGIN - - result = api_set_int_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) + // SPAvector + if (PyType_Ready(&a3dp_type_SPAvector) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs) -{ - const char *input_name = NULL; - const char *input_value = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "name", - (char *) "value", - NULL - }; + Py_INCREF(&a3dp_type_SPAvector); + PyModule_AddObject(m, "SPAvector", (PyObject *) &a3dp_type_SPAvector); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &input_name, &input_value)) + // SPAunit_vector + if (PyType_Ready(&a3dp_type_SPAunitvector) < 0) return NULL; + Py_INCREF(&a3dp_type_SPAunitvector); + PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &a3dp_type_SPAunitvector); - API_BEGIN - - result = api_set_str_option(input_name, input_value); - - API_END - - // Check outcome - if (!check_outcome(result)) + // SPApar_pos + if (PyType_Ready(&a3dp_type_SPAparpos) < 0) return NULL; - else - Py_RETURN_NONE; -} + Py_INCREF(&a3dp_type_SPAparpos); + PyModule_AddObject(m, "SPApar_pos", (PyObject *) &a3dp_type_SPAparpos); -static PyObject * -ACIS_api_solid_block(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pt1 = NULL, *input_pt2 = NULL, *input_block = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pt1", - (char *) "pt2", - (char *) "block", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_pt1, &input_pt2, &input_block)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_SPAposition(input_pt1)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_SPAposition(input_pt2)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_block)) - { - PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + // SPApar_vec + if (PyType_Ready(&a3dp_type_SPAparvec) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - SPAposition *_pt1 = ((ACIS_GeometricAtoms_SPAposition *) input_pt1)->_acis_obj; - SPAposition *_pt2 = ((ACIS_GeometricAtoms_SPAposition *) input_pt2)->_acis_obj; - BODY *&_block = (BODY *&) ((ACIS_Entity_BODY *) input_block)->base_obj._acis_obj; + Py_INCREF(&a3dp_type_SPAparvec); + PyModule_AddObject(m, "SPApar_vec", (PyObject *) &a3dp_type_SPAparvec); - // Call ACIS API - result = api_solid_block(*_pt1, *_pt2, _block); - - API_END - - // Check outcome - if (!check_outcome(result)) + if (PyType_Ready(&a3dp_type_FileInfo) < 0) return NULL; - else - Py_RETURN_NONE; -} -static PyObject * -ACIS_api_make_cuboid(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_x, input_y, input_z; - PyObject *input_body = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "x", - (char *) "y", - (char *) "z", - (char *) "body", - NULL - }; + Py_INCREF(&a3dp_type_FileInfo); + PyModule_AddObject(m, "FileInfo", (PyObject *) &a3dp_type_FileInfo); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddO", kwlist, &input_x, &input_y, &input_z, &input_body)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_body)) + // Create a dictionary object for NDBOOL_KEEP enum + PyObject *_ndbk_dict; + _ndbk_dict = PyDict_New(); + if (_ndbk_dict != NULL) { - PyErr_SetString(PyExc_TypeError, "The fourth argument must be a BODY object"); - return NULL; + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_NEITHER", PyLong_FromLong(0L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_TOOL", PyLong_FromLong(1L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BLANK", PyLong_FromLong(2L)); + PyDict_SetItemString(_ndbk_dict, "NDBOOL_KEEP_BOTH", PyLong_FromLong(3L)); } - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_body = (BODY *&) ((ACIS_Entity_BODY *) input_body)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_cuboid(input_x, input_y, input_z, _body); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_frustum(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2, input_top; - PyObject *input_frust = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "top", - (char *) "frust", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_frust)) + // NDBOOL_KEEP + a3dp_type_NDBOOLKEEP.tp_dict = _ndbk_dict; + if (PyType_Ready(&a3dp_type_NDBOOLKEEP) < 0) return NULL; + Py_INCREF(&a3dp_type_NDBOOLKEEP); + PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &a3dp_type_NDBOOLKEEP); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_frust)) + // Create a dictionary object for sweep_bool_type enum + PyObject *_sbt_dict; + _sbt_dict = PyDict_New(); + if (_sbt_dict != NULL) { - PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); - return NULL; + PyDict_SetItemString(_sbt_dict, "UNITE", PyLong_FromLong(0L)); + PyDict_SetItemString(_sbt_dict, "INTERSECT", PyLong_FromLong(1L)); + PyDict_SetItemString(_sbt_dict, "SUBTRACT", PyLong_FromLong(2L)); + PyDict_SetItemString(_sbt_dict, "LIMIT", PyLong_FromLong(3L)); + PyDict_SetItemString(_sbt_dict, "KEEP_BOTH", PyLong_FromLong(4L)); } - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_frust = (BODY *&) ((ACIS_Entity_BODY *) input_frust)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_frustum(input_height, input_radius1, input_radius2, input_top, _frust); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_prism(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2; - int input_nsides; - PyObject *input_prism = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "nsides", - (char *) "frust", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_nsides, &input_prism)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_prism)) - { - PyErr_SetString(PyExc_TypeError, "The fifth argument must be a BODY object"); + // sweep_bool_type + a3dp_type_sweepbooltype.tp_dict = _sbt_dict; + if (PyType_Ready(&a3dp_type_sweepbooltype) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_prism = (BODY *&) ((ACIS_Entity_BODY *) input_prism)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_prism(input_height, input_radius1, input_radius2, input_nsides, _prism); + Py_INCREF(&a3dp_type_sweepbooltype); + PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &a3dp_type_sweepbooltype); - API_END - - // Check outcome - if (!check_outcome(result)) + // sweep_options + if (PyType_Ready(&a3dp_type_sweep_options) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_pyramid(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_height, input_radius1, input_radius2, input_top; - int input_nsides; - PyObject *input_pyramid = NULL; + Py_INCREF(&a3dp_type_sweep_options); + PyModule_AddObject(m, "sweep_options", (PyObject *) &a3dp_type_sweep_options); - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "height", - (char *) "radius1", - (char *) "radius2", - (char *) "top", - (char *) "nsides", - (char *) "pyramid", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_height, &input_radius1, &input_radius2, &input_top, &input_nsides, &input_pyramid)) + // make_sweep_path_options + if (PyType_Ready(&a3dp_type_make_sweep_path_options) < 0) return NULL; + Py_INCREF(&a3dp_type_make_sweep_path_options); + PyModule_AddObject(m, "make_sweep_path_options", (PyObject *) &a3dp_type_make_sweep_path_options); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_pyramid)) - { - PyErr_SetString(PyExc_TypeError, "The sixth argument must be a BODY object"); + // Add ENTITY to the module + if (PyType_Ready(&a3dp_type_ENTITY) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_pyramid = (BODY *&) ((ACIS_Entity_BODY *) input_pyramid)->base_obj._acis_obj; + Py_INCREF(&a3dp_type_ENTITY); + PyModule_AddObject(m, "ENTITY", (PyObject *) &a3dp_type_ENTITY); - // Call ACIS API - result = api_make_pyramid(input_height, input_radius1, input_radius2, input_top, input_nsides, _pyramid); - - API_END - - // Check outcome - if (!check_outcome(result)) + // Add BODY to the module + a3dp_type_BODY.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_BODY) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_sphere(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_radius; - PyObject *input_sph = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "radius", - (char *) "sph", - NULL - }; + Py_INCREF(&a3dp_type_BODY); + PyModule_AddObject(m, "BODY", (PyObject *) &a3dp_type_BODY); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_radius, &input_sph)) + // Add FACE to the module + a3dp_type_FACE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_FACE) < 0) return NULL; + Py_INCREF(&a3dp_type_FACE); + PyModule_AddObject(m, "FACE", (PyObject *) &a3dp_type_FACE); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_sph)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a BODY object"); + // Add EDGE to the module + a3dp_type_EDGE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_EDGE) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_sph = (BODY *&) ((ACIS_Entity_BODY *) input_sph)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_sphere(input_radius, _sph); - - API_END + Py_INCREF(&a3dp_type_EDGE); + PyModule_AddObject(m, "EDGE", (PyObject *) &a3dp_type_EDGE); - // Check outcome - if (!check_outcome(result)) + // Add WIRE to the module + a3dp_type_WIRE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_WIRE) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_make_torus(PyObject *self, PyObject *args, PyObject *kwargs) -{ - double input_major_r, input_minor_r; - PyObject *input_tor = NULL; + Py_INCREF(&a3dp_type_WIRE); + PyModule_AddObject(m, "WIRE", (PyObject *) &a3dp_type_WIRE); - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "major_radius", - (char *) "minor_radius", - (char *) "tor", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddddiO", kwlist, &input_major_r, &input_minor_r, &input_tor)) + // Add LUMP to the module + a3dp_type_LUMP.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_LUMP) < 0) return NULL; + Py_INCREF(&a3dp_type_LUMP); + PyModule_AddObject(m, "LUMP", (PyObject *) &a3dp_type_LUMP); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_tor)) - { - PyErr_SetString(PyExc_TypeError, "The third argument must be a BODY object"); + // Add SHELL to the module + a3dp_type_SHELL.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SHELL) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - BODY *&_tor = (BODY *&) ((ACIS_Entity_BODY *) input_tor)->base_obj._acis_obj; - - // Call ACIS API - result = api_make_torus(input_major_r, input_minor_r, _tor); + Py_INCREF(&a3dp_type_SHELL); + PyModule_AddObject(m, "SHELL", (PyObject *) &a3dp_type_SHELL); - API_END - - // Check outcome - if (!check_outcome(result)) + // Add SUBSHELL to the module + a3dp_type_SUBSHELL.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SUBSHELL) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_apply_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_entity = NULL, *input_trans = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "entity", - (char *) "trans", - NULL - }; + Py_INCREF(&a3dp_type_SUBSHELL); + PyModule_AddObject(m, "SUBSHELL", (PyObject *) &a3dp_type_SUBSHELL); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity, &input_trans)) + // Add COEDGE to the module + a3dp_type_COEDGE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_COEDGE) < 0) return NULL; + Py_INCREF(&a3dp_type_COEDGE); + PyModule_AddObject(m, "COEDGE", (PyObject *) &a3dp_type_COEDGE); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_entity)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + // Add LOOP to the module + a3dp_type_LOOP.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_LOOP) < 0) return NULL; - } + Py_INCREF(&a3dp_type_LOOP); + PyModule_AddObject(m, "LOOP", (PyObject *) &a3dp_type_LOOP); - if (!_ACIS_check_SPAtransf(input_trans)) - { - PyErr_SetString(PyExc_TypeError, "The second argument must be a SPAtransf object"); + // Add VERTEX to the module + a3dp_type_VERTEX.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_VERTEX) < 0) return NULL; - } - - API_BEGIN - - // Convert PyObject to ACIS objects - ENTITY *&_entity = ((ACIS_Entity_BODY *) input_entity)->base_obj._acis_obj; - SPAtransf *&_trans = ((ACIS_GeometricAtoms_SPAtransf *) input_trans)->_acis_obj; - - // Call ACIS API - result = api_apply_transf(_entity, *_trans); + Py_INCREF(&a3dp_type_VERTEX); + PyModule_AddObject(m, "VERTEX", (PyObject *) &a3dp_type_VERTEX); - API_END - - // Check outcome - if (!check_outcome(result)) + // Add SURFACE to the module + a3dp_type_SURFACE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SURFACE) < 0) return NULL; - else - Py_RETURN_NONE; -} + Py_INCREF(&a3dp_type_SURFACE); + PyModule_AddObject(m, "SURFACE", (PyObject *) &a3dp_type_SURFACE); -static PyObject * -ACIS_api_remove_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_entity = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "entity", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_entity)) + // Add CONE to the module + a3dp_type_CONE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_CONE) < 0) return NULL; + Py_INCREF(&a3dp_type_CONE); + PyModule_AddObject(m, "CONE", (PyObject *) &a3dp_type_CONE); - // Type checks for ACIS objects - if (!_ACIS_check_BODY(input_entity)) - { - PyErr_SetString(PyExc_TypeError, "The first argument must be a BODY object"); + // Add PLANE to the module + a3dp_type_PLANE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_PLANE) < 0) return NULL; - } - - API_BEGIN + Py_INCREF(&a3dp_type_PLANE); + PyModule_AddObject(m, "PLANE", (PyObject *) &a3dp_type_PLANE); - // Convert PyObject to ACIS objects - ENTITY *&_entity = ((ACIS_Entity_BODY *) input_entity)->base_obj._acis_obj; - - // Call ACIS API - result = api_remove_transf(_entity); - - API_END - - // Check outcome - if (!check_outcome(result)) + // Add SPHERE to the module + a3dp_type_SPHERE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SPHERE) < 0) return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_sheet_from_ff(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_faces = NULL, *input_body = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "faces", - (char *) "body", - NULL - }; + Py_INCREF(&a3dp_type_SPHERE); + PyModule_AddObject(m, "SPHERE", (PyObject *) &a3dp_type_SPHERE); - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_faces, &input_body)) + // Add SPLINE to the module + a3dp_type_SPLINE.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_SPLINE) < 0) return NULL; + Py_INCREF(&a3dp_type_SPLINE); + PyModule_AddObject(m, "SPLINE", (PyObject *) &a3dp_type_SPLINE); - // First argument must be a tuple of faces - PyObject *seq = PySequence_Fast(input_faces, "First argument must be a sequence of FACE objects"); - - // ACIS API has a limitation in api_sheet_from_ff function: As of version R2017, it can handle only 1 face - Py_ssize_t face_array_size = PySequence_Fast_GET_SIZE(seq); - if (face_array_size <= 0) - { - PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); - Py_DECREF(seq); + // Add TORUS to the module + a3dp_type_TORUS.tp_base = &a3dp_type_ENTITY; + if (PyType_Ready(&a3dp_type_TORUS) < 0) return NULL; - } - else if (face_array_size > 1) - { - PyErr_WarnEx(PyExc_Warning, "ACIS API does not support generation of sheet bodies from multiple faces.", 0); - } - - PyObject *faceobj = PySequence_Fast_GET_ITEM(seq, 0); - - API_BEGIN - - FACE *&_face = (FACE *&) ((ACIS_Entity_FACE *) faceobj)->base_obj._acis_obj; - - FACE *_faces[1]; - _faces[0] = _face; - - BODY *&_body = (BODY *&) ((ACIS_Entity_BODY *) input_body)->base_obj._acis_obj; - - result = api_sheet_from_ff(1, _faces, _body); - - API_END + Py_INCREF(&a3dp_type_TORUS); + PyModule_AddObject(m, "TORUS", (PyObject *) &a3dp_type_TORUS); - // PySequence_Fast generates a new reference - Py_DECREF(seq); - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error + // Add surface to the module + if (PyType_Ready(&a3dp_type_surface) < 0) return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - - - -static PyMethodDef - module_methods[] = - { - { "api_start_modeller", (PyCFunction) ACIS_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Starts the 3D ACIS Modeler" }, - { "api_stop_modeller", (PyCFunction) ACIS_api_stop_modeller, METH_NOARGS, "Stops the 3D ACIS Modeler" }, - { "is_modeler_started", (PyCFunction) ACIS_is_modeler_started, METH_NOARGS, "Checks if the 3D ACIS Modeler started" }, - { "api_start_modeler", (PyCFunction) ACIS_api_start_modeller, METH_VARARGS | METH_KEYWORDS, "Alternative way to call api_start_modeller()" }, - { "api_stop_modeler", (PyCFunction) ACIS_api_stop_modeller, METH_NOARGS, "Alternative way to call api_stop_modeller()" }, - { "api_set_dbl_option", (PyCFunction) ACIS_api_set_dbl_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given double" }, - { "api_set_int_option", (PyCFunction) ACIS_api_set_int_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given integer" }, - { "api_set_str_option", (PyCFunction) ACIS_api_set_str_option, METH_VARARGS | METH_KEYWORDS, "Sets the value of the specified option to the given string" }, - { "api_solid_block", (PyCFunction) ACIS_api_solid_block, METH_VARARGS | METH_KEYWORDS, "Creates a solid block given two positions on a diagonal of the block" }, - { "api_make_cuboid", (PyCFunction) ACIS_api_make_cuboid, METH_VARARGS | METH_KEYWORDS, "Creates cuboid of given width (x), depth (y) and height (z)" }, - { "api_make_frustum", (PyCFunction) ACIS_api_make_frustum, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical cone or cylinder of given height and radii" }, - { "api_make_prism", (PyCFunction) ACIS_api_make_prism, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical prism of given height, radii, and number of sides" }, - { "api_make_pyramid", (PyCFunction) ACIS_api_make_pyramid, METH_VARARGS | METH_KEYWORDS, "Creates an elliptical pyramid of given height, radii, and number of sides" }, - { "api_make_sphere", (PyCFunction) ACIS_api_make_sphere, METH_VARARGS | METH_KEYWORDS, "Creates a sphere of given radius, centered at the origin" }, - { "api_make_torus", (PyCFunction) ACIS_api_make_torus, METH_VARARGS | METH_KEYWORDS, "Creates a torus of given major and minor radii centered at the origin" }, - { "api_apply_transf", (PyCFunction) ACIS_api_apply_transf, METH_VARARGS | METH_KEYWORDS, "Changes the transform entity attached to a body" }, - { "api_remove_transf", (PyCFunction) ACIS_api_remove_transf, METH_VARARGS | METH_KEYWORDS, "Removes (discards) the transformation of a body" }, - { "api_sheet_from_ff", (PyCFunction) ACIS_api_sheet_from_ff, METH_VARARGS | METH_KEYWORDS, "Creates a sheet body as a copy of a face" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Modeler"; -const char *module_documentation = "3D ACIS Modeler main modeling component"; + Py_INCREF(&a3dp_type_surface); + PyModule_AddObject(m, "surface", (PyObject *) &a3dp_type_surface); -static struct PyModuleDef - ACIS_Modeler_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Modeler(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Modeler_module); - if (m == NULL) + // Initialize ACIS ENTITY_LIST class as a Python type + if (PyType_Ready(&a3dp_type_ENTITYLIST) < 0) return NULL; + Py_INCREF(&a3dp_type_ENTITYLIST); + PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &a3dp_type_ENTITYLIST); return m; } diff --git a/src/acis_modeler.h b/src/acis_modeler.h index c2b07aa..a7028bf 100644 --- a/src/acis_modeler.h +++ b/src/acis_modeler.h @@ -9,19 +9,12 @@ * */ -#ifndef ACIS_MODELER_H -#define ACIS_MODELER_H +#ifndef A3DPY_MODELER_H +#define A3DPY_MODELER_H #include +#include -#include -#include -#include +#include "acis_api.h" -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "acis_saverestore.h" -#include "acis_lists.h" -#include "utilities.h" - -#endif //!ACIS_MODELER_H +#endif // !A3DPY_MODELER_H diff --git a/src/acis_operators.cpp b/src/acis_operators.cpp new file mode 100644 index 0000000..a6a4a87 --- /dev/null +++ b/src/acis_operators.cpp @@ -0,0 +1,802 @@ +#include "acis_operators.h" + + +PyObject * +a3dp_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_origin = NULL, *input_x_axis = NULL, *input_y_axis = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "new_origin", + (char *) "new_x_axis", + (char *) "new_y_axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO", kwlist, &input_origin, &input_x_axis, &input_y_axis)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAposition(input_origin)) + { + PyErr_SetString(PyExc_TypeError, "First parameter (new_origin) must be a SPAposition object"); + return NULL; + } + + if (!_PyCheck_SPAunit_vector(input_x_axis)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (new_x_axis) must be a SPAunit_vector object"); + return NULL; + } + + if (!_PyCheck_SPAunit_vector(input_y_axis)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (new_y_axis) must be a SPAunit_vector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAposition *&_new_origin = ((a3dp_SPAposition *) input_origin)->_acis_obj; + SPAunit_vector *&_new_x_axis = ((a3dp_SPAunit_vector *) input_x_axis)->_acis_obj; + SPAunit_vector *&_new_y_axis = ((a3dp_SPAunit_vector *) input_y_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = coordinate_transf(*_new_origin, *_new_x_axis, *_new_y_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_make_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_affine = NULL, *input_translation = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "affine", + (char *) "translation", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_affine, &input_translation)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAmatrix(input_affine)) + { + PyErr_SetString(PyExc_TypeError, "First parameter (affine) must be a SPAmatrix object"); + return NULL; + } + + if (!_PyCheck_SPAvector(input_translation)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (translate) must be a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAmatrix *&_affine = ((a3dp_SPAmatrix *) input_affine)->_acis_obj; + SPAvector *&_translation = ((a3dp_SPAvector *) input_translation)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = make_transf(*_affine, *_translation); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_axis = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_axis)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAvector(input_axis)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_axis = ((a3dp_SPAvector *) input_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = reflect_transf(*_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_axis = NULL; + double input_angle; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "angle", + (char *) "axis", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dO", kwlist, &input_angle, &input_axis)) + return NULL; + + // Check inputs + if (!_PyCheck_SPAvector(input_axis)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_axis = ((a3dp_SPAvector *) input_axis)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = rotate_transf(input_angle, *_axis); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL, *input_arg6 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "scale", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOOO", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5, &input_arg6)) + return NULL; + + SPAtransf retval; + + if (!PyFloat_Check(input_arg1)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg1 = PyFloat_AsDouble(input_arg1); + + if (input_arg2 != NULL || input_arg3 != NULL) + { + if (!PyFloat_Check(input_arg2) && !PyFloat_Check(input_arg3)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg2 = PyFloat_AsDouble(input_arg2); + double _arg3 = PyFloat_AsDouble(input_arg3); + + if (input_arg4 != NULL || input_arg5 != NULL || input_arg6 != NULL) + { + if (!PyFloat_Check(input_arg4) && !PyFloat_Check(input_arg5) && !PyFloat_Check(input_arg5)) + { + PyErr_SetString(PyExc_TypeError, "Expecting a floating-point number"); + return NULL; + } + + double _arg4 = PyFloat_AsDouble(input_arg4); + double _arg5 = PyFloat_AsDouble(input_arg5); + double _arg6 = PyFloat_AsDouble(input_arg5); + + retval = scale_transf(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6); + } + else + { + retval = scale_transf(_arg1, _arg2, _arg3); + } + } + else + { + retval = scale_transf(_arg1); + } + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double _shear_xy, _shear_xz, _shear_yz; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "shearxy", + (char *) "shearxz", + (char *) "shearyz", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddd", kwlist, &_shear_xy, &_shear_xz, &_shear_yz)) + return NULL; + + // Execute ACIS function + SPAtransf retval = shear_transf(_shear_xy, _shear_xz, _shear_yz); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_disp = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "disp", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_disp)) + return NULL; + + // "disp" must be a SPAvector object + if (!_PyCheck_SPAvector(input_disp)) + { + PyErr_SetString(PyExc_TypeError, "Expecting SPAvector object"); + return NULL; + } + + // Get the ACIS object from the user input + SPAvector *&_disp = ((a3dp_SPAvector *) input_disp)->_acis_obj; + + // Execute ACIS function + SPAtransf retval = translate_transf(*_disp); + + // Generate a new SPAtransf python object and set its ACIS object value + PyObject *retobj = _PyNew_SPAtransf(); + *((a3dp_SPAtransf *) retobj)->_acis_obj = retval; + + // Return SPAtransf python object + return retobj; +} + +PyObject * +a3dp_angle_between(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL, *input_z = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "z", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist, &input_v1, &input_v2, &input_z)) + return NULL; + + // Set return value + double _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + if (input_z != NULL) + { + if (!_PyCheck_SPAvector(input_z)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_z = ((a3dp_SPAunit_vector *) input_z)->_acis_obj; + + _retval = angle_between(*_v1, *_v2, *_z); + } + else + { + _retval = angle_between(*_v1, *_v2); + } + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_z != NULL) + { + if (!_PyCheck_SPAunit_vector(input_z)) + { + PyErr_SetString(PyExc_TypeError, "Third parameter (z) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_z = ((a3dp_SPAunit_vector *) input_z)->_acis_obj; + + _retval = angle_between(*_v1, *_v2, *_z); + } + else + { + _retval = angle_between(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return PyFloat object + return PyFloat_FromDouble(_retval); +} + +PyObject * +a3dp_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + double input_res = -1.0; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "res", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2) || !_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = antiparallel(*_v1, *_v2, input_res); + } + else + { + _retval = antiparallel(*_v1, *_v2); + } + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2) || !_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector or SPAvector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = antiparallel(*_v1, *_v2, input_res); + } + else + { + _retval = antiparallel(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + int input_same_dir = 0; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "same_dir", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i", kwlist, &input_v1, &input_v2, &input_same_dir)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + _retval = are_parallel(*_v1, *_v2, input_same_dir); + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + _retval = are_parallel(*_v1, *_v2, input_same_dir); + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_v1, &input_v2)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + _retval = are_perpendicular(*_v1, *_v2); + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + _retval = are_perpendicular(*_v1, *_v2); + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_biparallel(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_v1 = NULL, *input_v2 = NULL; + double input_res = -1.0; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "v1", + (char *) "v2", + (char *) "res", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|d", kwlist, &input_v1, &input_v2, &input_res)) + return NULL; + + // Set return value + logical _retval; + + // SPAvector scenario + if (_PyCheck_SPAvector(input_v1)) + { + if (!_PyCheck_SPAvector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAvector object"); + return NULL; + } + + SPAvector *&_v1 = ((a3dp_SPAvector *) input_v1)->_acis_obj; + SPAvector *&_v2 = ((a3dp_SPAvector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = biparallel(*_v1, *_v2, input_res); + } + else + { + _retval = biparallel(*_v1, *_v2); + } + } + else if (_PyCheck_SPAunit_vector(input_v1)) + { + // SPAunit_vector scenario + if (!_PyCheck_SPAunit_vector(input_v2)) + { + PyErr_SetString(PyExc_TypeError, "Second parameter (v2) should be a SPAunit_vector object"); + return NULL; + } + + SPAunit_vector *&_v1 = ((a3dp_SPAunit_vector *) input_v1)->_acis_obj; + SPAunit_vector *&_v2 = ((a3dp_SPAunit_vector *) input_v2)->_acis_obj; + + if (input_res >= 0.0) + { + _retval = biparallel(*_v1, *_v2, input_res); + } + else + { + _retval = biparallel(*_v1, *_v2); + } + } + else + { + PyErr_SetString(PyExc_TypeError, "First parameter (v1) should be a SPAvector or SPAunit_vector object"); + return NULL; + } + + // Return logical + if (_retval == 1) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject * +a3dp_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_ang; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ang", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) + return NULL; + + double _retval = degrees_to_radians(input_ang); + + // Return double + return PyFloat_FromDouble(_retval); +} + +PyObject * +a3dp_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs) +{ + double input_ang; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "ang", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_ang)) + return NULL; + + double _retval = radians_to_degrees(input_ang); + + // Return double + return PyFloat_FromDouble(_retval); +} + +PyObject * +a3dp_get_resabs(PyObject *self) +{ + return PyFloat_FromDouble(get_resabs()); +} + +PyObject * +a3dp_get_resfit(PyObject *self) +{ + return PyFloat_FromDouble(get_resfit()); +} + +PyObject * +a3dp_get_resmch(PyObject *self) +{ + return PyFloat_FromDouble(get_resmch()); +} + +PyObject * +a3dp_get_resnor(PyObject *self) +{ + return PyFloat_FromDouble(get_resnor()); +} + +PyObject * +a3dp_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) + return NULL; + + if (!_PyCheck_SPAposition(input_pt1) || !_PyCheck_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); + return NULL; + } + + SPAposition *&_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; + SPAposition *&_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; + + // Return double + return PyFloat_FromDouble(distance_to_point(*_pt1, *_pt2)); +} + +PyObject * +a3dp_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *input_pt1 = NULL, *input_pt2 = NULL; + + // List of keyword arguments that this function can take + char *kwlist[] = + { + (char *) "pt1", + (char *) "pt2", + NULL + }; + + // Try to parse input arguments and/or keywords + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pt1, &input_pt2)) + return NULL; + + if (!_PyCheck_SPAposition(input_pt1) || !_PyCheck_SPAposition(input_pt2)) + { + PyErr_SetString(PyExc_TypeError, "Input values should be SPAposition objects"); + return NULL; + } + + SPAposition *&_pt1 = ((a3dp_SPAposition *) input_pt1)->_acis_obj; + SPAposition *&_pt2 = ((a3dp_SPAposition *) input_pt2)->_acis_obj; + + // Return double + return PyFloat_FromDouble(distance_to_point_squared(*_pt1, *_pt2)); +} diff --git a/src/acis_operators.h b/src/acis_operators.h new file mode 100644 index 0000000..52e2047 --- /dev/null +++ b/src/acis_operators.h @@ -0,0 +1,50 @@ +/** + * + * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler + * + * ACIS and SAT are registered trademarks of Spatial Corporation. + * + * The Python module is developed by Onur R. Bingol and released under MIT license. + * Please see the LICENSE file for details. + * + */ + +#ifndef A3DPY_OPERATORS_H +#define A3DPY_OPERATORS_H + +#include +#include + +#include "acis_includes.h" +#include "acis_classes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +PyObject *a3dp_distance_to_point_squared(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_distance_to_point(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_get_resnor(PyObject *self); +PyObject *a3dp_get_resmch(PyObject *self); +PyObject *a3dp_get_resfit(PyObject *self); +PyObject *a3dp_get_resabs(PyObject *self); +PyObject *a3dp_radians_to_degrees(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_degrees_to_radians(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_biparallel(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_are_perpendicular(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_are_parallel(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_antiparallel(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_angle_between(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_shear_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_scale_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_rotate_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_reflect_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_make_transf(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *a3dp_coordinate_transf(PyObject *self, PyObject *args, PyObject *kwargs); + +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_OPERATORS_H diff --git a/src/acis_query.cpp b/src/acis_query.cpp deleted file mode 100644 index 5a84d17..0000000 --- a/src/acis_query.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include "acis_query.h" - - -static PyObject * -ACIS_Query_method_get_owner_transf(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "entity", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_ent)) - return NULL; - - if (!_ACIS_check_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - // Get the ACIS object from the user input - ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; - - // Execute ACIS function - SPAtransf retval = get_owner_transf(_ent); - - // Generate a new SPAtransf python object and set its ACIS object value - PyObject *retobj = _ACIS_new_SPAtransf(); - *((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval; - - // Return SPAtransf python object - return retobj; -} - -static PyObject * -ACIS_api_get_faces(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL, *input_ent_list = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ent", - (char *) "face_list", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) - return NULL; - - if (!_ACIS_check_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - if (!_ACIS_check_ENTITY_LIST(input_ent_list)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - API_BEGIN - - // Get the ACIS objects from the user input - ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; - ENTITY_LIST *&_face_list = ((ACIS_Lists_ENTITY_LIST *) input_ent_list)->_acis_obj; - - // Call ACIS function - result = api_get_faces(_ent, *_face_list); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } - -} - -static PyObject * -ACIS_api_get_edges(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_ent = NULL, *input_ent_list = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "ent", - (char *) "edge_list", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_ent, &input_ent_list)) - return NULL; - - if (!_ACIS_check_ENTITY(input_ent)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY object"); - return NULL; - } - - if (!_ACIS_check_ENTITY_LIST(input_ent_list)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - API_BEGIN - - // Get the ACIS objects from the user input - ENTITY *&_ent = ((ACIS_Entity_ENTITY *) input_ent)->_acis_obj; - ENTITY_LIST *&_edge_list = ((ACIS_Lists_ENTITY_LIST *) input_ent_list)->_acis_obj; - - // Call ACIS function - result = api_get_edges(_ent, *_edge_list); - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } - -} - -static PyMethodDef - module_methods[] = - { - { "get_owner_transf", (PyCFunction) ACIS_Query_method_get_owner_transf, METH_VARARGS | METH_KEYWORDS, "Gets a copy of the SPAtransf from the owner of an ENTITY" }, - { "api_get_faces", (PyCFunction) ACIS_api_get_faces, METH_VARARGS | METH_KEYWORDS, "Gets all faces related to an entity" }, - { "api_get_edges", (PyCFunction) ACIS_api_get_edges, METH_VARARGS | METH_KEYWORDS, "Gets all the edges related to an entity" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Query"; -const char *module_documentation = "Contains 3D Modeler ACIS geometric and topological queries"; - -static struct PyModuleDef - ACIS_Query_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Query(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Query_module); - if (m == NULL) - return NULL; - - return m; -} diff --git a/src/acis_saverestore.cpp b/src/acis_saverestore.cpp deleted file mode 100644 index 6a3f1a9..0000000 --- a/src/acis_saverestore.cpp +++ /dev/null @@ -1,506 +0,0 @@ -#include "acis_saverestore.h" - - -/** - * Save & Restore - FileInfo wrapper - */ - -static void -ACIS_SaveRestore_dealloc_FileInfo(ACIS_SaveRestore_FileInfo *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - // Delete the python object itself - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_SaveRestore_new_FileInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_SaveRestore_FileInfo *self; - - self = (ACIS_SaveRestore_FileInfo *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_SaveRestore_init_FileInfo(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - self->_acis_obj = ACIS_NEW FileInfo(); - return 0; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_acis_version(ACIS_SaveRestore_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->acis_version()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_date(ACIS_SaveRestore_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->date()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_file_version(ACIS_SaveRestore_FileInfo *self) -{ - return PyLong_FromLong((long) self->_acis_obj->file_version()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_product_id(ACIS_SaveRestore_FileInfo *self) -{ - return PyUnicode_FromString(self->_acis_obj->product_id()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_reset(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->reset(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_reset_vars(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->reset_vars(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_restore(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->restore(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_save(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->save(); - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_set_masked(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - unsigned long input_field; - PyObject *input_file = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "field", - (char *) "file", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "lO", kwlist, &input_field, &input_file)) - return NULL; - - // Check if the user input is a FileInfo object - if (_ACIS_check_FileInfo(input_file)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - // Convert PyObject to ENTITY_LIST - FileInfo *_file = ((ACIS_SaveRestore_FileInfo *) input_file)->_acis_obj; - - // Execute ACIS function - self->_acis_obj->set_masked(input_field, *_file); - - // Return None - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_set_product_id(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - const char *input_id = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "id", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &input_id)) - return NULL; - - self->_acis_obj->set_product_id(input_id); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_set_units(ACIS_SaveRestore_FileInfo *self, PyObject *args, PyObject *kwargs) -{ - double input_count; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "count", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d", kwlist, &input_count)) - return NULL; - - self->_acis_obj->set_units(input_count); - - Py_RETURN_NONE; -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_tol_abs(ACIS_SaveRestore_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->tol_abs()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_tol_nor(ACIS_SaveRestore_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->tol_nor()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_units(ACIS_SaveRestore_FileInfo *self) -{ - return PyFloat_FromDouble(self->_acis_obj->units()); -} - -static PyObject * -ACIS_SaveRestore_method_FileInfo_valid(ACIS_SaveRestore_FileInfo *self) -{ - self->_acis_obj->valid(); - Py_RETURN_NONE; -} - -static PyMemberDef - ACIS_SaveRestore_members_FileInfo[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_SaveRestore_methods_FileInfo[] = - { - { "acis_version", (PyCFunction) ACIS_SaveRestore_method_FileInfo_acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, - { "date", (PyCFunction) ACIS_SaveRestore_method_FileInfo_date, METH_NOARGS, "Returns the date on the save file" }, - { "file_version", (PyCFunction) ACIS_SaveRestore_method_FileInfo_file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, - { "product_id", (PyCFunction) ACIS_SaveRestore_method_FileInfo_product_id, METH_NOARGS, "Returns the ID of the product" }, - { "reset", (PyCFunction) ACIS_SaveRestore_method_FileInfo_reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, - { "reset_vars", (PyCFunction) ACIS_SaveRestore_method_FileInfo_reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, - { "restore", (PyCFunction) ACIS_SaveRestore_method_FileInfo_restore, METH_NOARGS, "Restores the file information from a save file" }, - { "save", (PyCFunction) ACIS_SaveRestore_method_FileInfo_save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, - //{ "set_masked", (PyCFunction)ACIS_SaveRestore_method_FileInfo_set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, - { "set_product_id", (PyCFunction) ACIS_SaveRestore_method_FileInfo_set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, - { "set_units", (PyCFunction) ACIS_SaveRestore_method_FileInfo_set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, - { "tol_abs", (PyCFunction) ACIS_SaveRestore_method_FileInfo_tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, - { "tol_nor", (PyCFunction) ACIS_SaveRestore_method_FileInfo_tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, - { "units", (PyCFunction) ACIS_SaveRestore_method_FileInfo_units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, - { "valid", (PyCFunction) ACIS_SaveRestore_method_FileInfo_valid, METH_NOARGS, "Checks the values of the units and product id" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_SaveRestore_type_FileInfo = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FileInfo", /* tp_name */ - sizeof(ACIS_SaveRestore_FileInfo), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_SaveRestore_dealloc_FileInfo, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "FileInfo object contains additional required save file header information", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_SaveRestore_methods_FileInfo, /* tp_methods */ - ACIS_SaveRestore_members_FileInfo, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_SaveRestore_init_FileInfo, /* tp_init */ - 0, /* tp_alloc */ - ACIS_SaveRestore_new_FileInfo, /* tp_new */ - }; - - -/** - * Save & Restore Interface Functions - */ - -static PyObject * -ACIS_api_save_entity_list(PyObject *self, PyObject *args, PyObject *kwargs) -{ - // According to the documentation, Python 3 doesn't do good with FILE* objects, so we take "file name" as an input - const char *input_filename = NULL; - int input_savemode; - PyObject *input_entitylist = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "file_name", - (char *) "text_mode", - (char *) "entity_list_save", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO", kwlist, &input_filename, &input_savemode, &input_entitylist)) - return NULL; - - // Check if the input is an ENTITY_LIST - if (!_ACIS_check_ENTITY_LIST(input_entitylist)) - { - PyErr_SetString(PyExc_TypeError, "Expecting ENTITY_LIST object"); - return NULL; - } - - // Using the file name input as a string, create a file handle - FILE *_file_handle = fopen(input_filename, "w"); - - // Check if the file has been opened correctly - if (_file_handle == NULL) - { - PyErr_SetString(PyExc_IOError, "Cannot open file for writing!"); - return NULL; - } - - // Set file writing mode - logical _text_mode = (input_savemode == 0) ? FALSE : TRUE; - - API_NOP_BEGIN - - // Convert PyObject to ENTITY_LIST - ENTITY_LIST *_save_list = ((ACIS_Lists_ENTITY_LIST *) input_entitylist)->_acis_obj; - - - // Call ACIS API and check outcome - result = api_save_entity_list(_file_handle, _text_mode, *_save_list); - - API_NOP_END - - // Don't forget to close the file handle - fclose(_file_handle); - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_set_file_info(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_product_id = 0; - int input_units = 0; - PyObject *input_info = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "info", - (char *) "product_id", - (char *) "units", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii", kwlist, &input_info, &input_product_id, &input_units)) - return NULL; - - // Check if we have a FileInfo object - if (!_ACIS_check_FileInfo(input_info)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - // Set up the value of mask - bool _product_id = input_product_id != 0; - bool _units = input_units != 0; - - unsigned long _mask; - if (_product_id && !_units) - { - _mask = FileIdent; - } - else if (!_product_id && _units) - { - _mask = FileUnits; - } - else - { - _mask = FileUnits | FileIdent; - } - - API_BEGIN - - // Convert PyObject to FileInfo - FileInfo *_info = ((ACIS_SaveRestore_FileInfo *) input_info)->_acis_obj; - - result = api_set_file_info(_mask, *_info); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_get_file_info(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_info = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "info", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_info)) - return NULL; - - // Check if we have a FileInfo object - if (_ACIS_check_FileInfo(input_info)) - { - PyErr_SetString(PyExc_TypeError, "Expecting FileInfo object"); - return NULL; - } - - API_BEGIN - - // Convert PyObject to FileInfo - FileInfo *_info = ((ACIS_SaveRestore_FileInfo *) input_info)->_acis_obj; - - result = api_get_file_info(*_info); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - -static PyObject * -ACIS_api_save_version(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int input_major_version, input_minor_version; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "major_version", - (char *) "minor_version", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &input_major_version, &input_minor_version)) - return NULL; - - API_BEGIN - - result = api_save_version(input_major_version, input_minor_version); - - API_END - - // Check outcome - if (!check_outcome(result)) - return NULL; - else - Py_RETURN_NONE; -} - - -static PyMethodDef - module_methods[] = - { - { "api_save_entity_list", (PyCFunction) ACIS_api_save_entity_list, METH_VARARGS | METH_KEYWORDS, "Writes entities to a file in text or binary format" }, - { "api_set_file_info", (PyCFunction) ACIS_api_set_file_info, METH_VARARGS | METH_KEYWORDS, "Sets required header info to be written to ACIS save files" }, - { "api_get_file_info", (PyCFunction) ACIS_api_get_file_info, METH_O | METH_KEYWORDS, "Gets header info from the last restored file" }, - { "api_save_version", (PyCFunction) ACIS_api_save_version, METH_VARARGS | METH_KEYWORDS, "Sets the save file format" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "SaveRestore"; -const char *module_documentation = "Contains 3D ACIS Modeler save & restore related classes and functions"; - -static PyModuleDef - ACIS_SaveRestore_module = - { - PyModuleDef_HEAD_INIT, - module_name, - module_documentation, - -1, - module_methods - }; - -PyMODINIT_FUNC -PyInit_SaveRestore(void) -{ - PyObject *m; - m = PyModule_Create(&ACIS_SaveRestore_module); - if (m == NULL) - return NULL; - - if (PyType_Ready(&ACIS_SaveRestore_type_FileInfo) < 0) - return NULL; - - Py_INCREF(&ACIS_SaveRestore_type_FileInfo); - PyModule_AddObject(m, "FileInfo", (PyObject *) &ACIS_SaveRestore_type_FileInfo); - - return m; -} - -bool _ACIS_check_FileInfo(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_SaveRestore_type_FileInfo; -} diff --git a/src/acis_saverestore.h b/src/acis_saverestore.h deleted file mode 100644 index a7b4505..0000000 --- a/src/acis_saverestore.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_SAVERESTORE_H -#define ACIS_SAVERESTORE_H - -#include -#include - -#include -#include - -#include "acis_lists.h" -#include "utilities.h" - -#include "acis_saverestore_export.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -// Define FileInfo -typedef struct -{ - PyObject_HEAD - FileInfo *_acis_obj; -} ACIS_SaveRestore_FileInfo; - -bool ACIS_SAVERESTORE_EXPORT _ACIS_check_FileInfo(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_SAVERESTORE_H diff --git a/src/acis_spa.cpp b/src/acis_spa.cpp new file mode 100644 index 0000000..5e867d3 --- /dev/null +++ b/src/acis_spa.cpp @@ -0,0 +1,25 @@ +#include "acis_spa.h" + + +PyObject * +a3dp_spa_unlock_products(PyObject *self, PyObject *arg) +{ + // Check if the input is a string + if (!PyUnicode_Check(arg)) + { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; + } + + // Convert PyObject to C-style string + const char *unlock_str = PyUnicode_AsUTF8(arg); + + // Call ACIS Licensing API + spa_unlock_result out = spa_unlock_products(unlock_str); + + // If license is good, then return True. Otherwise, return the licensing error message + if (SPA_UNLOCK_PASS == out.get_state()) + Py_RETURN_TRUE; + else + return PyUnicode_FromString(out.get_message_text()); +} diff --git a/src/acis_query.h b/src/acis_spa.h similarity index 53% rename from src/acis_query.h rename to src/acis_spa.h index e176d95..9764acd 100644 --- a/src/acis_query.h +++ b/src/acis_spa.h @@ -9,18 +9,21 @@ * */ -#ifndef ACIS_GEOMETRIC_OPERATORS_H -#define ACIS_GEOMETRIC_OPERATORS_H +#ifndef A3D_SPA_H +#define A3D_SPA_H #include -#include +#include "acis_includes.h" -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "acis_lists.h" -#include "utilities.h" +#ifdef __cplusplus +extern "C" { +#endif -#include "acis_query_export.h" +PyObject *a3dp_spa_unlock_products(PyObject *self, PyObject *arg); -#endif // !ACIS_GEOMETRIC_OPERATORS_H +#ifdef __cplusplus +} +#endif + +#endif // !A3D_SPA_H diff --git a/src/acis_sweeping.cpp b/src/acis_sweeping.cpp deleted file mode 100644 index 89f6e65..0000000 --- a/src/acis_sweeping.cpp +++ /dev/null @@ -1,551 +0,0 @@ -#include "acis_sweeping.h" - - -/** - * make_sweep_path_options class - */ - -static void -ACIS_Sweeping_dealloc_SweepPathOptions(ACIS_Sweeping_SweepPathOptions *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_Sweeping_new_SweepPathOptions(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_Sweeping_SweepPathOptions *self; - - self = (ACIS_Sweeping_SweepPathOptions *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_Sweeping_init_SweepPathOptions(ACIS_Sweeping_SweepPathOptions *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW make_sweep_path_options(); - - return 0; -} - -static PyMemberDef - ACIS_Sweeping_members_SweepPathOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Sweeping_methods_SweepPathOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Sweeping_type_SweepPathOptions = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.make_sweep_path_options", /* tp_name */ - sizeof(ACIS_Sweeping_SweepPathOptions), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Sweeping_dealloc_SweepPathOptions, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Sweeping_methods_SweepPathOptions, /* tp_methods */ - ACIS_Sweeping_members_SweepPathOptions, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Sweeping_init_SweepPathOptions, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Sweeping_new_SweepPathOptions, /* tp_new */ - }; - - -/** - * sweep_bool_type enum - */ - -static PyTypeObject - ACIS_Sweeping_type_SweepBoolType = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_bool_type", /* tp_name */ - sizeof(ACIS_Sweeping_SweepBoolType), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Sweep to body boolean operation type", /* tp_doc */ - }; - - -/** - * sweep_options class - */ - -static void -ACIS_Sweeping_dealloc_SweepOptions(ACIS_Sweeping_SweepOptions *self) -{ - // Delete ACIS object - ACIS_DELETE self->_acis_obj; - - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject * -ACIS_Sweeping_new_SweepOptions(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - ACIS_Sweeping_SweepOptions *self; - - self = (ACIS_Sweeping_SweepOptions *) type->tp_alloc(type, 0); - if (self != NULL) - { - // Just getting rid of the dangling pointer - self->_acis_obj = NULL; - } - - return (PyObject *) self; -} - -static int -ACIS_Sweeping_init_SweepOptions(ACIS_Sweeping_SweepOptions *self, PyObject *args, PyObject *kwargs) -{ - // Initialize the ACIS object - self->_acis_obj = ACIS_NEW sweep_options(); - - return 0; -} - -static PyObject * -ACIS_Sweeping_method_SweepOptions_set_bool_type(ACIS_Sweeping_SweepOptions *self, PyObject *args, PyObject *kwargs) -{ - // Just a testing... - self->_acis_obj->set_bool_type(KEEP_BOTH); - - Py_RETURN_NONE; -} - -static PyGetSetDef - ACIS_Sweeping_getseters_SweepOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyMemberDef - ACIS_Sweeping_members_SweepOptions[] = - { - { NULL } /* Sentinel */ - }; - -static PyMethodDef - ACIS_Sweeping_methods_SweepOptions[] = - { - { "set_bool_type", (PyCFunction) ACIS_Sweeping_method_SweepOptions_set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - ACIS_Sweeping_type_SweepOptions = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_options", /* tp_name */ - sizeof(ACIS_Sweeping_SweepOptions), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) ACIS_Sweeping_dealloc_SweepOptions, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ACIS_Sweeping_methods_SweepOptions, /* tp_methods */ - ACIS_Sweeping_members_SweepOptions, /* tp_members */ - ACIS_Sweeping_getseters_SweepOptions, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) ACIS_Sweeping_init_SweepOptions, /* tp_init */ - 0, /* tp_alloc */ - ACIS_Sweeping_new_SweepOptions, /* tp_new */ - }; - - -/** - * Sweeping API Interface Functions - */ - -static PyObject * -ACIS_api_make_sweep_path(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_pts = NULL, *input_path = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "pts", - (char *) "path", - NULL - }; - - // Try to parse input arguments and/or keywords - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &input_pts, &input_path)) - return NULL; - - // Type checks for ACIS objects - if (!_ACIS_check_EDGE(input_path)) - { - PyErr_SetString(PyExc_TypeError, "Second argument (path) must be an EDGE object"); - return NULL; - } - - // The first object must be a python sequence containing SPAposition objects - PyObject *seq = PySequence_Fast(input_pts, "First argument (pts) must be a sequence of SPAposition objects, such as a list or a tuple"); - - Py_ssize_t position_vector_size = PySequence_Fast_GET_SIZE(seq); - if (position_vector_size <= 0) - { - PyErr_SetString(PyExc_ValueError, "Sequence cannot be empty"); - Py_DECREF(seq); - return NULL; - } - - // It seems unnecessary to implement a SPAposition container as python itself provides a handful of containers for every purpose - SPAposition_vector _pts; - - for (Py_ssize_t i = 0; i < position_vector_size; i++) - { - PyObject *pt_temp; - pt_temp = PySequence_Fast_GET_ITEM(seq, i); - if (!_ACIS_check_SPAposition(pt_temp)) - { - PyErr_SetString(PyExc_TypeError, "Sequence must contain SPAposition objects"); - Py_DECREF(seq); - return NULL; - } - _pts.push_back(*((ACIS_GeometricAtoms_SPAposition *) pt_temp)->_acis_obj); - } - - API_BEGIN - - EDGE *&_path = (EDGE *&) ((ACIS_Entity_EDGE *) input_path)->base_obj._acis_obj; - - // Don't use make_sweep_path_options for now - result = api_make_sweep_path(_pts, _path); - - API_END - - // PySequence_Fast returns a new reference - Py_DECREF(seq); - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Clear SPAposition container - _pts.clear(); - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyObject * -ACIS_api_sweep_with_options(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *input_arg1 = NULL, *input_arg2 = NULL, *input_arg3 = NULL, *input_arg4 = NULL, *input_arg5 = NULL; - - // List of keyword arguments that this function can take - static char *kwlist[] = - { - (char *) "arg1", - (char *) "arg2", - (char *) "arg3", - (char *) "arg4", - (char *) "arg5", - NULL - }; - - // Try to parse input arguments and/or keywords (hold sweep_options for now) - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO|O", kwlist, &input_arg1, &input_arg2, &input_arg3, &input_arg4, &input_arg5)) - return NULL; - - /* - * IMPORTANT NOTE: This function wraps all 4 api_sweep_with_options overloads in one single Python function. - * The reason is that Python doesn't allow overloading with same function names but different signatures. - */ - - // In all overloads, first argument is always an ENTITY object - if (!_ACIS_check_ENTITY(input_arg1)) - { - PyErr_SetString(PyExc_TypeError, "First argument must be an ENTITY object"); - return NULL; - } - - API_BEGIN - - ENTITY *&_ent = (ENTITY *&) ((ACIS_Entity_ENTITY *) input_arg1)->_acis_obj; - - // Check if we are using the sweep along the axis overload - if (input_arg5 != NULL) - { - if (!_ACIS_check_SPAposition(input_arg2)) - { - PyErr_SetString(PyExc_TypeError, "Second argument must be a SPAposition object"); - return NULL; - } - - if (!_ACIS_check_SPAvector(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Third argument must be a SPAvector object"); - return NULL; - } - - if (!_ACIS_check_SweepOptions(input_arg4)) - { - PyErr_SetString(PyExc_TypeError, "Fourth argument must be a sweep_options object"); - return NULL; - } - - if (!_ACIS_check_BODY(input_arg5)) - { - PyErr_SetString(PyExc_TypeError, "Fifth argument must be a BODY object"); - return NULL; - } - - SPAposition *&_root = (SPAposition *&) ((ACIS_GeometricAtoms_SPAposition *) input_arg2)->_acis_obj; - SPAvector *&_axis = (SPAvector *&) ((ACIS_GeometricAtoms_SPAvector *) input_arg3)->_acis_obj; - sweep_options *&_opts = (sweep_options *&) ((ACIS_Sweeping_SweepOptions *) input_arg4)->_acis_obj; - BODY *&_new_body = (BODY *&) ((ACIS_Entity_BODY *) input_arg5)->base_obj._acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, *_root, *_axis, _opts, _new_body); - - } - else - { - // We must be using the other overloads, then the 3rd argument must be a sweep_options object - if (!_ACIS_check_SweepOptions(input_arg3)) - { - PyErr_SetString(PyExc_TypeError, "Third argument must be a sweep_options object"); - return NULL; - } - - sweep_options *&_opts = (sweep_options *&) ((ACIS_Sweeping_SweepOptions *) input_arg3)->_acis_obj; - - // and the 4th argument must be a BODY object - if (!_ACIS_check_BODY(input_arg4)) - { - PyErr_SetString(PyExc_TypeError, "Fourth argument must be a BODY object"); - return NULL; - } - - BODY *&_new_body = (BODY *&) ((ACIS_Entity_BODY *) input_arg4)->base_obj._acis_obj; - - // Check for sweeping along a given edge or a wire overload - if (_ACIS_check_ENTITY(input_arg2)) - { - ENTITY *&_path = (ENTITY *&) ((ACIS_Entity_ENTITY *) input_arg2)->_acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, _path, _opts, _new_body); - } - else if (PyFloat_Check(input_arg2)) - { - // We must be using sweeping along a specified distance overload - double _distance = PyFloat_AsDouble(input_arg2); - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, _distance, _opts, _new_body); - } - else if (_ACIS_check_SPAvector(input_arg2)) - { - // We must be using sweeping along a specified vector overload - SPAvector *&_vec = (SPAvector *&) ((ACIS_GeometricAtoms_SPAvector *) input_arg2)->_acis_obj; - - // Call ACIS Sweeping API - result = api_sweep_with_options(_ent, *_vec, _opts, _new_body); - } - else - { - PyErr_SetString(PyExc_TypeError, "Second argument must be an ENTITY, float or SPAvector object"); - return NULL; - } - - } - - API_END - - // Check outcome - if (!check_outcome(result)) - { - // Returning NULL means that we have an error - return NULL; - } - else - { - // Returning none means that we have no errors - Py_RETURN_NONE; - } -} - -static PyMethodDef - module_methods[] = - { - { "api_make_sweep_path", (PyCFunction) ACIS_api_make_sweep_path, METH_VARARGS | METH_KEYWORDS, "Constructs a path useful for creating a swept surface" }, - { "api_sweep_with_options", (PyCFunction) ACIS_api_sweep_with_options, METH_VARARGS | METH_KEYWORDS, "Sweeps the given profile along an edge, a distance, a vector or an axis" }, - { NULL, NULL, 0, NULL } - }; - -// Module documentation can be accessible via __doc__ -const char *module_name = "Sweeping"; -const char *module_documentation = "Contains 3D ACIS Modeler sweeping API related classes and functions"; - -static struct PyModuleDef - ACIS_Sweeping_module = - { - PyModuleDef_HEAD_INIT, - module_name, // name of the module - module_documentation, // module documentation, may be NULL - -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. - module_methods - }; - -PyMODINIT_FUNC -PyInit_Sweeping(void) -{ - PyObject *m; - - m = PyModule_Create(&ACIS_Sweeping_module); - if (m == NULL) - return NULL; - - // Create a dictionary object for sweep_bool_type enum - PyObject *_sbt_dict; - _sbt_dict = PyDict_New(); - if (_sbt_dict != NULL) - { - PyDict_SetItemString(_sbt_dict, "UNITE", PyLong_FromLong(0L)); - PyDict_SetItemString(_sbt_dict, "INTERSECT", PyLong_FromLong(1L)); - PyDict_SetItemString(_sbt_dict, "SUBTRACT", PyLong_FromLong(2L)); - PyDict_SetItemString(_sbt_dict, "LIMIT", PyLong_FromLong(3L)); - PyDict_SetItemString(_sbt_dict, "KEEP_BOTH", PyLong_FromLong(4L)); - } - - // sweep_bool_type - ACIS_Sweeping_type_SweepBoolType.tp_dict = _sbt_dict; - if (PyType_Ready(&ACIS_Sweeping_type_SweepBoolType) < 0) - return NULL; - Py_INCREF(&ACIS_Sweeping_type_SweepBoolType); - PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &ACIS_Sweeping_type_SweepBoolType); - - // sweep_options - if (PyType_Ready(&ACIS_Sweeping_type_SweepOptions) < 0) - return NULL; - Py_INCREF(&ACIS_Sweeping_type_SweepOptions); - PyModule_AddObject(m, "sweep_options", (PyObject *) &ACIS_Sweeping_type_SweepOptions); - - // make_sweep_path_options - if (PyType_Ready(&ACIS_Sweeping_type_SweepPathOptions) < 0) - return NULL; - Py_INCREF(&ACIS_Sweeping_type_SweepPathOptions); - PyModule_AddObject(m, "make_sweep_path_options", (PyObject *) &ACIS_Sweeping_type_SweepPathOptions); - - return m; -} - -PyObject *_ACIS_new_SweepBoolType() -{ - return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepBoolType, NULL); -} - -bool _ACIS_check_SweepBoolType(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepBoolType; -} - -PyObject *_ACIS_new_SweepOptions() -{ - return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepOptions, NULL); -} - -bool _ACIS_check_SweepOptions(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepOptions; -} - -PyObject *_ACIS_new_SweepPathOptions() -{ - return PyObject_CallObject((PyObject *) &ACIS_Sweeping_type_SweepPathOptions, NULL); -} - -bool _ACIS_check_SweepPathOptions(PyObject *ob) -{ - return Py_TYPE(ob) == &ACIS_Sweeping_type_SweepPathOptions; -} diff --git a/src/acis_sweeping.h b/src/acis_sweeping.h deleted file mode 100644 index 0a5d9da..0000000 --- a/src/acis_sweeping.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef ACIS_SWEEPING_H -#define ACIS_SWEEPING_H - -#include -#include - -#include -#include -#include -#include - -#include "acis_entity.h" -#include "acis_geometric_atoms.h" -#include "utilities.h" - -#include "acis_sweeping_export.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -// Define sweep_bool_type enum -typedef struct { - PyObject_HEAD -} ACIS_Sweeping_SweepBoolType; - -PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepBoolType(); - -bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepBoolType(PyObject *ob); - -// Define sweep_options -typedef struct -{ - PyObject_HEAD - sweep_options *_acis_obj; -} ACIS_Sweeping_SweepOptions; - -PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepOptions(); - -bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepOptions(PyObject *ob); - -// Define make_sweep_path_options -typedef struct -{ - PyObject_HEAD - make_sweep_path_options *_acis_obj; -} ACIS_Sweeping_SweepPathOptions; - -PyObject ACIS_SWEEPING_EXPORT *_ACIS_new_SweepPathOptions(); - -bool ACIS_SWEEPING_EXPORT _ACIS_check_SweepPathOptions(PyObject *ob); - -#ifdef __cplusplus -} -#endif - -#endif // !ACIS_SWEEPING_H diff --git a/src/utilities.h b/src/utilities.h index dec548b..8129a90 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -9,14 +9,21 @@ * */ -#ifndef ACIS_UTILITIES_H -#define ACIS_UTILITIES_H +#ifndef A3DPY_UTILITIES_H +#define A3DPY_UTILITIES_H #include -#include -#include +#include "acis_includes.h" + +#ifdef __cplusplus +extern "C" { +#endif bool check_outcome(outcome &_retval); -#endif //ACIS_UTILITIES_H +#ifdef __cplusplus +} +#endif + +#endif // !A3DPY_UTILITIES_H From b6077fd6e99cb86efde0b52967bd2ef8f47aec22 Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Sun, 10 Dec 2017 03:05:17 -0600 Subject: [PATCH 8/9] Fix issues after reorganization --- CMakeLists.txt | 2 - src/acis_api.cpp | 31 +- src/acis_api.h | 2 +- src/acis_classes.cpp | 903 +++++++++++++++++++++----- src/acis_classes.h | 785 ++--------------------- src/acis_entity.cpp | 1456 ++++++++++++++++++++++++++++++++++-------- src/acis_entity.h | 1144 +++------------------------------ src/acis_enums.cpp | 67 +- src/acis_enums.h | 72 +-- src/acis_modeler.cpp | 40 +- src/acis_spa.cpp | 25 - src/acis_spa.h | 29 - 12 files changed, 2161 insertions(+), 2395 deletions(-) delete mode 100644 src/acis_spa.cpp delete mode 100644 src/acis_spa.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 969c389..b710582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,8 +128,6 @@ set( ACIS_SOURCES_Modeler src/acis_enums.h src/acis_operators.cpp src/acis_operators.h - src/acis_spa.cpp - src/acis_spa.h src/utilities.cpp src/utilities.h ) diff --git a/src/acis_api.cpp b/src/acis_api.cpp index 44442ce..98810d1 100644 --- a/src/acis_api.cpp +++ b/src/acis_api.cpp @@ -84,6 +84,29 @@ a3dp_is_modeler_started(PyObject *self) Py_RETURN_FALSE; } +PyObject * +a3dp_spa_unlock_products(PyObject *self, PyObject *arg) +{ + // Check if the input is a string + if (!PyUnicode_Check(arg)) + { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; + } + + // Convert PyObject to C-style string + const char *unlock_str = PyUnicode_AsUTF8(arg); + + // Call ACIS Licensing API + spa_unlock_result out = spa_unlock_products(unlock_str); + + // If license is good, then return True. Otherwise, return the licensing error message + if (SPA_UNLOCK_PASS == out.get_state()) + Py_RETURN_TRUE; + else + return PyUnicode_FromString(out.get_message_text()); +} + PyObject * a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -706,7 +729,7 @@ a3dp_api_unite(PyObject *self, PyObject *args, PyObject *kwargs) else { // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); + __make_null(input_tool); // Returning none means that we have no errors Py_RETURN_NONE; } @@ -762,7 +785,7 @@ a3dp_api_intersect(PyObject *self, PyObject *args, PyObject *kwargs) else { // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); + __make_null(input_tool); // Returning none means that we have no errors Py_RETURN_NONE; } @@ -818,7 +841,7 @@ a3dp_api_subtract(PyObject *self, PyObject *args, PyObject *kwargs) else { // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); + __make_null(input_tool); // Returning none means that we have no errors Py_RETURN_NONE; } @@ -874,7 +897,7 @@ a3dp_api_imprint(PyObject *self, PyObject *args, PyObject *kwargs) else { // Boolean operations automatically delete tool bodies, but for python, we need to set reference to NULL too - _a3dp_make_null(input_tool); + __make_null(input_tool); // Returning none means that we have no errors Py_RETURN_NONE; } diff --git a/src/acis_api.h b/src/acis_api.h index 0e7f970..0be2dbe 100644 --- a/src/acis_api.h +++ b/src/acis_api.h @@ -20,7 +20,6 @@ #include "acis_operators.h" #include "acis_classes.h" #include "acis_enums.h" -#include "acis_spa.h" #include "utilities.h" #ifdef __cplusplus @@ -30,6 +29,7 @@ extern "C" { PyObject *a3dp_api_start_modeller(PyObject *self, PyObject *args, PyObject *kwargs); PyObject *a3dp_api_stop_modeller(PyObject *self); PyObject *a3dp_is_modeler_started(PyObject *self); +PyObject *a3dp_spa_unlock_products(PyObject *self, PyObject *arg); PyObject *a3dp_api_set_dbl_option(PyObject *self, PyObject *args, PyObject *kwargs); PyObject *a3dp_api_set_int_option(PyObject *self, PyObject *args, PyObject *kwargs); PyObject *a3dp_api_set_str_option(PyObject *self, PyObject *args, PyObject *kwargs); diff --git a/src/acis_classes.cpp b/src/acis_classes.cpp index 049a475..b7474f4 100644 --- a/src/acis_classes.cpp +++ b/src/acis_classes.cpp @@ -1,12 +1,11 @@ #include "acis_classes.h" - /** * SPAposition wrapper */ -void +static void a3dp_SPAposition_dealloc(a3dp_SPAposition *self) { // Delete ACIS object @@ -16,7 +15,7 @@ a3dp_SPAposition_dealloc(a3dp_SPAposition *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_SPAposition *self; @@ -31,7 +30,7 @@ a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) { double input_x = 0.0, input_y = 0.0, input_z = 0.0; @@ -53,7 +52,7 @@ a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPAposition_repr(a3dp_SPAposition *self) { double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); @@ -73,7 +72,7 @@ a3dp_SPAposition_repr(a3dp_SPAposition *self) return PyUnicode_FromFormat("SPAposition object (%s, %s, %s)", _x, _y, _z); } -PyObject * +static PyObject * a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -102,7 +101,7 @@ a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg) return PyFloat_FromDouble(self->_acis_obj->coordinate(_i)); } -PyObject * +static PyObject * a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs) { int _i; @@ -130,7 +129,7 @@ a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObjec Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -164,7 +163,7 @@ a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -198,7 +197,7 @@ a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -232,69 +231,137 @@ a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAposition__x(a3dp_SPAposition *self) { return PyFloat_FromDouble(self->_acis_obj->x()); } -PyObject * +static PyObject * a3dp_SPAposition__y(a3dp_SPAposition *self) { return PyFloat_FromDouble(self->_acis_obj->y()); } -PyObject * +static PyObject * a3dp_SPAposition__z(a3dp_SPAposition *self) { return PyFloat_FromDouble(self->_acis_obj->z()); } -PyObject * +static PyObject * a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure) { return a3dp_SPAposition__x(self); } -PyObject * +static PyObject * a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure) { return a3dp_SPAposition__y(self); } -PyObject * +static PyObject * a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure) { return a3dp_SPAposition__z(self); } -int +static int a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure) { a3dp_SPAposition__set_x(self, value); return 0; } -int +static int a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure) { a3dp_SPAposition__set_y(self, value); return 0; } -int +static int a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure) { a3dp_SPAposition__set_z(self, value); return 0; } -bool _PyCheck_SPAposition(PyObject *ob) +static PyGetSetDef + a3dp_getseters_SPAposition[] = + { + { (char *) "x_value", (getter) a3dp_SPAposition_x_getter, (setter) a3dp_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, + { (char *) "y_value", (getter) a3dp_SPAposition_y_getter, (setter) a3dp_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, + { (char *) "z_value", (getter) a3dp_SPAposition_z_getter, (setter) a3dp_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAposition[] = + { + { "coordinate", (PyCFunction) a3dp_SPAposition__coordinate, METH_O, "Returns the i-th component value" }, + { "set_coordinate", (PyCFunction) a3dp_SPAposition__set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, + { "set_x", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the x-coordinate value" }, + { "set_y", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the y-coordinate value" }, + { "set_z", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the z-coordinate value" }, + { "x", (PyCFunction) a3dp_SPAposition__x, METH_NOARGS, "Returns the x-coordinate value" }, + { "y", (PyCFunction) a3dp_SPAposition__y, METH_NOARGS, "Returns the y-coordinate value" }, + { "z", (PyCFunction) a3dp_SPAposition__z, METH_NOARGS, "Returns the z-coordinate value" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SPAposition = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAposition", /* tp_name */ + sizeof(a3dp_SPAposition), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAposition_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAposition_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAposition_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAposition, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAposition, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAposition_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAposition_new, /* tp_new */ + }; + +bool +_PyCheck_SPAposition(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPAposition; + return PyObject_TypeCheck(ob, &a3dp_type_SPAposition); } -PyObject *_PyNew_SPAposition() +PyObject * +_PyNew_SPAposition() { return PyObject_CallObject((PyObject *) &a3dp_type_SPAposition, NULL); } @@ -303,7 +370,7 @@ PyObject *_PyNew_SPAposition() * SPAvector class */ -void +static void a3dp_SPAvector_dealloc(a3dp_SPAvector *self) { // Delete ACIS object @@ -313,7 +380,7 @@ a3dp_SPAvector_dealloc(a3dp_SPAvector *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_SPAvector *self; @@ -328,7 +395,7 @@ a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) { double input_x = 0.0, input_y = 0.0, input_z = 0.0; @@ -350,7 +417,7 @@ a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPAvector_repr(a3dp_SPAvector *self) { double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); @@ -370,7 +437,7 @@ a3dp_SPAvector_repr(a3dp_SPAvector *self) return PyUnicode_FromFormat("SPAvector object (%s, %s, %s)", _x, _y, _z); } -PyObject * +static PyObject * a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -399,7 +466,7 @@ a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg) return PyFloat_FromDouble(self->_acis_obj->component(_i)); } -PyObject * +static PyObject * a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs) { int _i; @@ -427,7 +494,7 @@ a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kw Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -461,7 +528,7 @@ a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -495,7 +562,7 @@ a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -529,78 +596,147 @@ a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAvector__x(a3dp_SPAvector *self) { return PyFloat_FromDouble(self->_acis_obj->x()); } -PyObject * +static PyObject * a3dp_SPAvector__y(a3dp_SPAvector *self) { return PyFloat_FromDouble(self->_acis_obj->y()); } -PyObject * +static PyObject * a3dp_SPAvector__z(a3dp_SPAvector *self) { return PyFloat_FromDouble(self->_acis_obj->z()); } -PyObject * +static PyObject * a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure) { return a3dp_SPAvector__x(self); } -PyObject * +static PyObject * a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure) { return a3dp_SPAvector__y(self); } -PyObject * +static PyObject * a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure) { return a3dp_SPAvector__z(self); } -int +static int a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure) { a3dp_SPAvector__set_x(self, value); return 0; } -int +static int a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure) { a3dp_SPAvector__set_y(self, value); return 0; } -int +static int a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure) { a3dp_SPAvector__set_z(self, value); return 0; } -bool _PyCheck_SPAvector(PyObject *ob) +static PyGetSetDef + a3dp_getseters_SPAvector[] = + { + { (char *) "x_value", (getter) a3dp_SPAvector_x_getter, (setter) a3dp_SPAvector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) a3dp_SPAvector_y_getter, (setter) a3dp_SPAvector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) a3dp_SPAvector_z_getter, (setter) a3dp_SPAvector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAvector[] = + { + { "component", (PyCFunction) a3dp_SPAvector__component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) a3dp_SPAvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) a3dp_SPAvector__x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) a3dp_SPAvector__y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) a3dp_SPAvector__z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SPAvector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAvector", /* tp_name */ + sizeof(a3dp_SPAvector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAvector_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAvector_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAvector_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAvector, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAvector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAvector_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAvector_new, /* tp_new */ + }; + +bool +_PyCheck_SPAvector(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPAvector; + return PyObject_TypeCheck(ob, &a3dp_type_SPAvector); } -PyObject *_PyNew_SPAvector() +PyObject * +_PyNew_SPAvector() { return PyObject_CallObject((PyObject *) &a3dp_type_SPAvector, NULL); } + /** * SPAunit_vector wrapper */ -void +static void a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self) { // Delete ACIS object @@ -610,7 +746,7 @@ a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_SPAunit_vector *self; @@ -625,7 +761,7 @@ a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) { double input_x = 0.0, input_y = 0.0, input_z = 0.0; @@ -647,7 +783,7 @@ a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwa return 0; } -PyObject * +static PyObject * a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self) { double x = self->_acis_obj->x(); double y = self->_acis_obj->y(); double z = self->_acis_obj->z(); @@ -667,7 +803,7 @@ a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self) return PyUnicode_FromFormat("SPAunit_vector object (%s, %s, %s)", _x, _y, _z); } -PyObject * +static PyObject * a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -696,7 +832,7 @@ a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg) return PyFloat_FromDouble(self->_acis_obj->component(_i)); } -PyObject * +static PyObject * a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs) { int _i; @@ -724,7 +860,7 @@ a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyO Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -758,7 +894,7 @@ a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -792,7 +928,7 @@ a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -826,78 +962,146 @@ a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self) { return PyFloat_FromDouble(self->_acis_obj->x()); } -PyObject * +static PyObject * a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self) { return PyFloat_FromDouble(self->_acis_obj->y()); } -PyObject * +static PyObject * a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self) { return PyFloat_FromDouble(self->_acis_obj->z()); } -PyObject * +static PyObject * a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) { return a3dp_SPAunitvector__x(self); } -PyObject * +static PyObject * a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) { return a3dp_SPAunitvector__y(self); } -PyObject * +static PyObject * a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) { return a3dp_SPAunitvector__z(self); } -int +static int a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) { a3dp_SPAunitvector__set_x(self, value); return 0; } -int +static int a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) { a3dp_SPAunitvector__set_y(self, value); return 0; } -int +static int a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure) { a3dp_SPAunitvector__set_z(self, value); return 0; } -bool _PyCheck_SPAunit_vector(PyObject *ob) +static PyGetSetDef + a3dp_getseters_SPAunit_vector[] = + { + { (char *) "x_value", (getter) a3dp_SPAunitvector_x_getter, (setter) a3dp_SPAunitvector_x_setter, (char *) "value of the x component", NULL }, + { (char *) "y_value", (getter) a3dp_SPAunitvector_y_getter, (setter) a3dp_SPAunitvector_y_setter, (char *) "value of the y component", NULL }, + { (char *) "z_value", (getter) a3dp_SPAunitvector_z_getter, (setter) a3dp_SPAunitvector_z_setter, (char *) "value of the z component", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_SPAunit_vector[] = + { + { "component", (PyCFunction) a3dp_SPAunitvector__component, METH_O, "Returns the i-th component of the vector" }, + { "set_component", (PyCFunction) a3dp_SPAunitvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, + { "set_x", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the x-component of the vector" }, + { "set_y", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the y-component of the vector" }, + { "set_z", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the z-component of the vector" }, + { "x", (PyCFunction) a3dp_SPAunitvector__x, METH_NOARGS, "Returns the x-component of the vector" }, + { "y", (PyCFunction) a3dp_SPAunitvector__y, METH_NOARGS, "Returns the y-component of the vector" }, + { "z", (PyCFunction) a3dp_SPAunitvector__z, METH_NOARGS, "Returns the z-component of the vector" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SPAunit_vector = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAunit_vector", /* tp_name */ + sizeof(a3dp_SPAunit_vector), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAunitvector_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAunitvector_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAunitvector_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAunit_vector, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAunit_vector, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAunitvector_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAunitvector_new, /* tp_new */ + }; + +bool +_PyCheck_SPAunit_vector(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPAunitvector; + return PyObject_TypeCheck(ob, &a3dp_type_SPAunit_vector); } -PyObject *_PyNew_SPAunit_vector() +PyObject * +_PyNew_SPAunit_vector() { - return PyObject_CallObject((PyObject *) &a3dp_type_SPAunitvector, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SPAunit_vector, NULL); } /** * SPAmatrix wrapper */ -void +static void a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self) { // Delete ACIS object @@ -907,7 +1111,7 @@ a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_SPAmatrix *self; @@ -922,7 +1126,7 @@ a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) { // Initialize the ACIS object @@ -931,7 +1135,7 @@ a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg) { // Treat the input argument as a borrowed reference @@ -959,7 +1163,7 @@ a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg) return _python_ret; } -PyObject * +static PyObject * a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg) { // Treat the input argument as a borrowed reference @@ -987,7 +1191,7 @@ a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg) return _python_ret; } -PyObject * +static PyObject * a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self) { // Create a new SPAmatrix python object @@ -1000,7 +1204,7 @@ a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self) return _python_ret; } -PyObject * +static PyObject * a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self) { // Create a new SPAmatrix python object @@ -1013,14 +1217,14 @@ a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self) return _python_ret; } -PyObject * +static PyObject * a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self) { // Execute the ACIS function and return the value as a python object return PyFloat_FromDouble(self->_acis_obj->determinant()); } -PyObject * +static PyObject * a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) { int input_row, input_col; @@ -1041,7 +1245,7 @@ a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) return PyFloat_FromDouble(self->_acis_obj->element(input_row, input_col)); } -PyObject * +static PyObject * a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs) { int input_row, input_col; @@ -1066,7 +1270,7 @@ a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwar Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self) { logical _ret_val = self->_acis_obj->is_identity(); @@ -1077,12 +1281,71 @@ a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self) Py_RETURN_FALSE; } -bool _PyCheck_SPAmatrix(PyObject *ob) +static PyMethodDef + a3dp_methods_SPAmatrix[] = + { + { "column", (PyCFunction) a3dp_SPAmatrix__column, METH_O, "Extracts a column from this matrix" }, + { "row", (PyCFunction) a3dp_SPAmatrix__row, METH_O, "Extracts a row from this matrix" }, + { "element", (PyCFunction) a3dp_SPAmatrix__element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, + { "set_element", (PyCFunction) a3dp_SPAmatrix__set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, + { "determinant", (PyCFunction) a3dp_SPAmatrix__determinant, METH_NOARGS, "Returns the determinant of this matrix" }, + { "transpose", (PyCFunction) a3dp_SPAmatrix__transpose, METH_NOARGS, "Returns a transpose of this matrix" }, + { "inverse", (PyCFunction) a3dp_SPAmatrix__inverse, METH_NOARGS, "Returns the inverse of this matrix" }, + { "is_identity", (PyCFunction) a3dp_SPAmatrix__is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SPAmatrix = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAmatrix", /* tp_name */ + sizeof(a3dp_SPAmatrix), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAmatrix_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAmatrix, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAmatrix_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAmatrix_new, /* tp_new */ + }; + +bool +_PyCheck_SPAmatrix(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPAmatrix; + return PyObject_TypeCheck(ob, &a3dp_type_SPAmatrix); } -PyObject *_PyNew_SPAmatrix() +PyObject +*_PyNew_SPAmatrix() { return PyObject_CallObject((PyObject *) &a3dp_type_SPAmatrix, NULL); } @@ -1091,7 +1354,7 @@ PyObject *_PyNew_SPAmatrix() * SPAtransf wrapper */ -void +static void a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self) { // Delete ACIS object @@ -1101,7 +1364,7 @@ a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_SPAtransf *self; @@ -1116,7 +1379,7 @@ a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs) { // Initialize the ACIS object @@ -1125,7 +1388,7 @@ a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPAtransf__affine(a3dp_SPAtransf *self) { PyObject *_ret = _PyNew_SPAmatrix(); @@ -1135,7 +1398,7 @@ a3dp_SPAtransf__affine(a3dp_SPAtransf *self) return _ret; } -PyObject * +static PyObject * a3dp_SPAtransf__inverse(a3dp_SPAtransf *self) { PyObject *_ret = _PyNew_SPAtransf(); @@ -1145,7 +1408,7 @@ a3dp_SPAtransf__inverse(a3dp_SPAtransf *self) return _ret; } -PyObject * +static PyObject * a3dp_SPAtransf__translation(a3dp_SPAtransf *self) { PyObject *_ret = _PyNew_SPAvector(); @@ -1155,7 +1418,7 @@ a3dp_SPAtransf__translation(a3dp_SPAtransf *self) return _ret; } -PyObject * +static PyObject * a3dp_SPAtransf__identity(a3dp_SPAtransf *self) { logical _check = self->_acis_obj->identity(); @@ -1166,7 +1429,7 @@ a3dp_SPAtransf__identity(a3dp_SPAtransf *self) Py_RETURN_FALSE; } -PyObject * +static PyObject * a3dp_SPAtransf__reflect(a3dp_SPAtransf *self) { logical _check = self->_acis_obj->reflect(); @@ -1177,7 +1440,7 @@ a3dp_SPAtransf__reflect(a3dp_SPAtransf *self) Py_RETURN_FALSE; } -PyObject * +static PyObject * a3dp_SPAtransf__rotate(a3dp_SPAtransf *self) { logical _check = self->_acis_obj->rotate(); @@ -1188,13 +1451,13 @@ a3dp_SPAtransf__rotate(a3dp_SPAtransf *self) Py_RETURN_FALSE; } -PyObject * +static PyObject * a3dp_SPAtransf__scaling(a3dp_SPAtransf *self) { return PyFloat_FromDouble(self->_acis_obj->scaling()); } -PyObject * +static PyObject * a3dp_SPAtransf__shear(a3dp_SPAtransf *self) { logical _check = self->_acis_obj->shear(); @@ -1205,13 +1468,71 @@ a3dp_SPAtransf__shear(a3dp_SPAtransf *self) Py_RETURN_FALSE; } +static PyMethodDef + a3dp_methods_SPAtransf[] = + { + { "affine", (PyCFunction) a3dp_SPAtransf__affine, METH_NOARGS, "Returns the affine portion of the transformation" }, + { "inverse", (PyCFunction) a3dp_SPAtransf__inverse, METH_NOARGS, "Returns the inverse transformation" }, + { "translation", (PyCFunction) a3dp_SPAtransf__translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, + { "identity", (PyCFunction) a3dp_SPAtransf__identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, + { "reflect", (PyCFunction) a3dp_SPAtransf__reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, + { "rotate", (PyCFunction) a3dp_SPAtransf__rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, + { "scaling", (PyCFunction) a3dp_SPAtransf__scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, + { "shear", (PyCFunction) a3dp_SPAtransf__shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SPAtransf = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(a3dp_SPAtransf), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAtransf_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPAtransf represents a general 3D affine transformation", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SPAtransf, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAtransf_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAtransf_new, /* tp_new */ + }; -bool _PyCheck_SPAtransf(PyObject *ob) +bool +_PyCheck_SPAtransf(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPAtransf; + return PyObject_TypeCheck(ob, &a3dp_type_SPAtransf); } -PyObject *_PyNew_SPAtransf() +PyObject * +_PyNew_SPAtransf() { return PyObject_CallObject((PyObject *) &a3dp_type_SPAtransf, NULL); } @@ -1220,7 +1541,7 @@ PyObject *_PyNew_SPAtransf() * SPApar_pos wrapper */ -void +static void a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self) { // Delete ACIS object @@ -1230,7 +1551,7 @@ a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_SPApar_pos *self; @@ -1245,7 +1566,7 @@ a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs) { // Initialize the ACIS object @@ -1254,7 +1575,7 @@ a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPAparpos_repr(a3dp_SPApar_pos *self) { double u = self->_acis_obj->u; double v = self->_acis_obj->v; @@ -1270,47 +1591,100 @@ a3dp_SPAparpos_repr(a3dp_SPApar_pos *self) return PyUnicode_FromFormat("SPApar_pos object (%s, %s)", _u, _v); } -PyObject * +static PyObject * a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) { return PyFloat_FromDouble(self->_acis_obj->u); } -int +static int a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) { self->_acis_obj->u = PyFloat_AsDouble(value); return 0; } -PyObject * +static PyObject * a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure) { return PyFloat_FromDouble(self->_acis_obj->v); } -int +static int a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure) { self->_acis_obj->v = PyFloat_AsDouble(value); return 0; } -bool _PyCheck_SPApar_pos(PyObject *ob) +static PyGetSetDef + a3dp_getseters_SPAparpos[] = + { + { (char *) "u", (getter) a3dp_SPAparpos_u_getter, (setter) a3dp_SPAparpos_u_setter, (char *) "value of the u parameter", NULL }, + { (char *) "v", (getter) a3dp_SPAparpos_v_getter, (setter) a3dp_SPAparpos_v_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SPApar_pos = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPAtransf", /* tp_name */ + sizeof(a3dp_SPApar_pos), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAparpos_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAparpos_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAparpos_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAparpos, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAparpos_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAparpos_new, /* tp_new */ + }; + +bool +_PyCheck_SPApar_pos(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPAparpos; + return PyObject_TypeCheck(ob, &a3dp_type_SPApar_pos); } -PyObject *_PyNew_SPApar_pos() +PyObject * +_PyNew_SPApar_pos() { - return PyObject_CallObject((PyObject *) &a3dp_type_SPAparpos, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SPApar_pos, NULL); } /** * SPApar_vec wrapper */ -void +static void a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self) { // Delete ACIS object @@ -1320,7 +1694,7 @@ a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_SPApar_vec *self; @@ -1335,7 +1709,7 @@ a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs) { // Initialize the ACIS object @@ -1344,7 +1718,7 @@ a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPAparvec_repr(a3dp_SPApar_vec *self) { double du = self->_acis_obj->du; double dv = self->_acis_obj->dv; @@ -1360,48 +1734,100 @@ a3dp_SPAparvec_repr(a3dp_SPApar_vec *self) return PyUnicode_FromFormat("SPApar_vec object (%s, %s)", _du, _dv); } -PyObject * +static PyObject * a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) { return PyFloat_FromDouble(self->_acis_obj->du); } -int +static int a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) { self->_acis_obj->du = PyFloat_AsDouble(value); return 0; } -PyObject * +static PyObject * a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure) { return PyFloat_FromDouble(self->_acis_obj->dv); } -int +static int a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure) { self->_acis_obj->dv = PyFloat_AsDouble(value); return 0; } -bool _PyCheck_SPApar_vec(PyObject *ob) +static PyGetSetDef + a3dp_getseters_SPAparvec[] = + { + { (char *) "du", (getter) a3dp_SPAparvec_du_getter, (setter) a3dp_SPAparvec_du_setter, (char *) "value of the u parameter", NULL }, + { (char *) "dv", (getter) a3dp_SPAparvec_dv_getter, (setter) a3dp_SPAparvec_dv_setter, (char *) "value of the v parameter", NULL }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SPApar_vec = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPApar_vec", /* tp_name */ + sizeof(a3dp_SPApar_vec), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_SPAparvec_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPAparvec_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPAparvec_repr, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_SPAparvec, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPAparvec_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_SPAparvec_new, /* tp_new */ + }; + +bool +_PyCheck_SPApar_vec(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_SPAparvec; + return PyObject_TypeCheck(ob, &a3dp_type_SPApar_vec); } -PyObject *_PyNew_SPApar_vec() +PyObject * +_PyNew_SPApar_vec() { - return PyObject_CallObject((PyObject *) &a3dp_type_SPAparvec, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_SPApar_vec, NULL); } - /** * FileInfo class */ -void +static void a3dp_FileInfo_dealloc(a3dp_FileInfo *self) { // Delete ACIS object @@ -1411,7 +1837,7 @@ a3dp_FileInfo_dealloc(a3dp_FileInfo *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_FileInfo *self; @@ -1426,66 +1852,66 @@ a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) { self->_acis_obj = ACIS_NEW FileInfo(); return 0; } -PyObject * +static PyObject * a3dp_FileInfo__acis_version(a3dp_FileInfo *self) { return PyUnicode_FromString(self->_acis_obj->acis_version()); } -PyObject * +static PyObject * a3dp_FileInfo__date(a3dp_FileInfo *self) { return PyUnicode_FromString(self->_acis_obj->date()); } -PyObject * +static PyObject * a3dp_FileInfo__file_version(a3dp_FileInfo *self) { return PyLong_FromLong((long) self->_acis_obj->file_version()); } -PyObject * +static PyObject * a3dp_FileInfo__product_id(a3dp_FileInfo *self) { return PyUnicode_FromString(self->_acis_obj->product_id()); } -PyObject * +static PyObject * a3dp_FileInfo__reset(a3dp_FileInfo *self) { self->_acis_obj->reset(); Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_FileInfo__reset_vars(a3dp_FileInfo *self) { self->_acis_obj->reset_vars(); Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_FileInfo__restore(a3dp_FileInfo *self) { self->_acis_obj->restore(); Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_FileInfo__save(a3dp_FileInfo *self) { self->_acis_obj->save(); Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) { unsigned long input_field; @@ -1520,7 +1946,7 @@ a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) { const char *input_id = NULL; @@ -1541,7 +1967,7 @@ a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwa Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) { double input_count; @@ -1562,38 +1988,106 @@ a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs) Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_FileInfo__tol_abs(a3dp_FileInfo *self) { return PyFloat_FromDouble(self->_acis_obj->tol_abs()); } -PyObject * +static PyObject * a3dp_FileInfo__tol_nor(a3dp_FileInfo *self) { return PyFloat_FromDouble(self->_acis_obj->tol_nor()); } -PyObject * +static PyObject * a3dp_FileInfo__units(a3dp_FileInfo *self) { return PyFloat_FromDouble(self->_acis_obj->units()); } -PyObject * +static PyObject * a3dp_FileInfo__valid(a3dp_FileInfo *self) { self->_acis_obj->valid(); Py_RETURN_NONE; } +static PyMethodDef + a3dp_methods_FileInfo[] = + { + { "acis_version", (PyCFunction) a3dp_FileInfo__acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, + { "date", (PyCFunction) a3dp_FileInfo__date, METH_NOARGS, "Returns the date on the save file" }, + { "file_version", (PyCFunction) a3dp_FileInfo__file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, + { "product_id", (PyCFunction) a3dp_FileInfo__product_id, METH_NOARGS, "Returns the ID of the product" }, + { "reset", (PyCFunction) a3dp_FileInfo__reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, + { "reset_vars", (PyCFunction) a3dp_FileInfo__reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, + { "restore", (PyCFunction) a3dp_FileInfo__restore, METH_NOARGS, "Restores the file information from a save file" }, + { "save", (PyCFunction) a3dp_FileInfo__save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, + //{ "set_masked", (PyCFunction)a3dp_FileInfo__set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, + { "set_product_id", (PyCFunction) a3dp_FileInfo__set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, + { "set_units", (PyCFunction) a3dp_FileInfo__set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, + { "tol_abs", (PyCFunction) a3dp_FileInfo__tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, + { "tol_nor", (PyCFunction) a3dp_FileInfo__tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, + { "units", (PyCFunction) a3dp_FileInfo__units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, + { "valid", (PyCFunction) a3dp_FileInfo__valid, METH_NOARGS, "Checks the values of the units and product id" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_FileInfo = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FileInfo", /* tp_name */ + sizeof(a3dp_FileInfo), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_FileInfo_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "FileInfo object contains additional required save file header information", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_FileInfo, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_FileInfo_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_FileInfo_new, /* tp_new */ + }; + bool _PyCheck_FileInfo(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_FileInfo; + return PyObject_TypeCheck(ob, &a3dp_type_FileInfo); } -void +/** + * make_sweep_path_options + */ + +static void a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self) { // Delete ACIS object @@ -1602,7 +2096,7 @@ a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_make_sweep_path_options *self; @@ -1617,7 +2111,7 @@ a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwar return (PyObject *) self; } -int +static int a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs) { // Initialize the ACIS object @@ -1626,7 +2120,67 @@ a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *arg return 0; } -void +PyTypeObject + a3dp_type_make_sweep_path_options = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.make_sweep_path_options", /* tp_name */ + sizeof(a3dp_make_sweep_path_options), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_makesweeppathoptions_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_makesweeppathoptions_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_makesweeppathoptions_new, /* tp_new */ + }; + +PyObject * +_PyNew_make_sweep_path_options() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_make_sweep_path_options, NULL); +} + +bool +_PyCheck_make_sweep_path_options(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_make_sweep_path_options); +} + + +/** + * sweep_options + */ + +static void a3dp_sweepoptions_dealloc(a3dp_sweep_options *self) { // Delete ACIS object @@ -1635,7 +2189,7 @@ a3dp_sweepoptions_dealloc(a3dp_sweep_options *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_sweep_options *self; @@ -1650,7 +2204,7 @@ a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) { // Initialize the ACIS object @@ -1659,7 +2213,7 @@ a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwarg return 0; } -PyObject * +static PyObject * a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs) { // Just a testing... @@ -1668,18 +2222,55 @@ a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObj Py_RETURN_NONE; } +static PyMethodDef + a3dp_methods_sweepoptions[] = + { + { "set_bool_type", (PyCFunction) a3dp_sweepoptions__set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, + { NULL } /* Sentinel */ + }; -PyObject * -_PyNew_make_sweep_path_options() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_make_sweep_path_options, NULL); -} - -bool -_PyCheck_make_sweep_path_options(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_make_sweep_path_options; -} +PyTypeObject + a3dp_type_sweep_options = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_options", /* tp_name */ + sizeof(a3dp_sweep_options), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_sweepoptions_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_sweepoptions, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_sweepoptions_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_sweepoptions_new, /* tp_new */ + }; PyObject * _PyNew_sweep_options() @@ -1690,5 +2281,5 @@ _PyNew_sweep_options() bool _PyCheck_sweep_options(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_sweep_options; + return PyObject_TypeCheck(ob, &a3dp_type_sweep_options); } diff --git a/src/acis_classes.h b/src/acis_classes.h index fff4746..a40ca33 100644 --- a/src/acis_classes.h +++ b/src/acis_classes.h @@ -19,10 +19,6 @@ #include "utilities.h" -#ifdef __cplusplus -extern "C" { -#endif - // Define SPAposition typedef struct { @@ -30,96 +26,6 @@ typedef struct SPAposition *_acis_obj; } a3dp_SPAposition; -void a3dp_SPAposition_dealloc(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAposition_init(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAposition_repr(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition__coordinate(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__set_coordinate(a3dp_SPAposition *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAposition__set_x(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__set_y(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__set_z(a3dp_SPAposition *self, PyObject *arg); -PyObject *a3dp_SPAposition__x(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition__y(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition__z(a3dp_SPAposition *self); -PyObject *a3dp_SPAposition_x_getter(a3dp_SPAposition *self, PyObject *value, void *closure); -PyObject *a3dp_SPAposition_y_getter(a3dp_SPAposition *self, PyObject *value, void *closure); -PyObject *a3dp_SPAposition_z_getter(a3dp_SPAposition *self, PyObject *value, void *closure); -int a3dp_SPAposition_x_setter(a3dp_SPAposition *self, PyObject *value, void *closure); -int a3dp_SPAposition_y_setter(a3dp_SPAposition *self, PyObject *value, void *closure); -int a3dp_SPAposition_z_setter(a3dp_SPAposition *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAposition[] = - { - { (char *) "x_value", (getter) a3dp_SPAposition_x_getter, (setter) a3dp_SPAposition_x_setter, (char *) "value of the x-coordinate", NULL }, - { (char *) "y_value", (getter) a3dp_SPAposition_y_getter, (setter) a3dp_SPAposition_y_setter, (char *) "value of the y-coordinate", NULL }, - { (char *) "z_value", (getter) a3dp_SPAposition_z_getter, (setter) a3dp_SPAposition_z_setter, (char *) "value of the z-coordinate", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_SPAposition[] = - { - { "coordinate", (PyCFunction) a3dp_SPAposition__coordinate, METH_O, "Returns the i-th component value" }, - { "set_coordinate", (PyCFunction) a3dp_SPAposition__set_coordinate, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component value" }, - { "set_x", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the x-coordinate value" }, - { "set_y", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the y-coordinate value" }, - { "set_z", (PyCFunction) a3dp_SPAposition__set_x, METH_O, "Sets the z-coordinate value" }, - { "x", (PyCFunction) a3dp_SPAposition__x, METH_NOARGS, "Returns the x-coordinate value" }, - { "y", (PyCFunction) a3dp_SPAposition__y, METH_NOARGS, "Returns the y-coordinate value" }, - { "z", (PyCFunction) a3dp_SPAposition__z, METH_NOARGS, "Returns the z-coordinate value" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAposition = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAposition", /* tp_name */ - sizeof(a3dp_SPAposition), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAposition_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAposition_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAposition_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAposition represents position vectors (points) in 3D Cartesian space that are subject to certain vector and transformation operations", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAposition, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAposition, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAposition_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAposition_new, /* tp_new */ - }; - - -PyObject *_PyNew_SPAposition(); - -bool _PyCheck_SPAposition(PyObject *ob); - // Define SPAvector typedef struct { @@ -127,95 +33,6 @@ typedef struct SPAvector *_acis_obj; } a3dp_SPAvector; -void a3dp_SPAvector_dealloc(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAvector_init(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAvector_repr(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector__component(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__set_component(a3dp_SPAvector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAvector__set_x(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__set_y(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__set_z(a3dp_SPAvector *self, PyObject *arg); -PyObject *a3dp_SPAvector__x(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector__y(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector__z(a3dp_SPAvector *self); -PyObject *a3dp_SPAvector_x_getter(a3dp_SPAvector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAvector_y_getter(a3dp_SPAvector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAvector_z_getter(a3dp_SPAvector *self, PyObject *value, void *closure); -int a3dp_SPAvector_x_setter(a3dp_SPAvector *self, PyObject *value, void *closure); -int a3dp_SPAvector_y_setter(a3dp_SPAvector *self, PyObject *value, void *closure); -int a3dp_SPAvector_z_setter(a3dp_SPAvector *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAvector[] = - { - { (char *) "x_value", (getter) a3dp_SPAvector_x_getter, (setter) a3dp_SPAvector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) a3dp_SPAvector_y_getter, (setter) a3dp_SPAvector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) a3dp_SPAvector_z_getter, (setter) a3dp_SPAvector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_SPAvector[] = - { - { "component", (PyCFunction) a3dp_SPAvector__component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) a3dp_SPAvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) a3dp_SPAvector__set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) a3dp_SPAvector__x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) a3dp_SPAvector__y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) a3dp_SPAvector__z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAvector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAvector", /* tp_name */ - sizeof(a3dp_SPAvector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAvector_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAvector_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAvector_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAvector represents a displacement vector in 3D Cartesian space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAvector, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAvector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAvector_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAvector_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAvector(); - -bool _PyCheck_SPAvector(PyObject *ob); - // Define SPAunit_vector typedef struct { @@ -223,95 +40,6 @@ typedef struct SPAunit_vector *_acis_obj; } a3dp_SPAunit_vector; -void a3dp_SPAunitvector_dealloc(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAunitvector_init(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAunitvector_repr(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector__component(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__set_component(a3dp_SPAunit_vector *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAunitvector__set_x(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__set_y(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__set_z(a3dp_SPAunit_vector *self, PyObject *arg); -PyObject *a3dp_SPAunitvector__x(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector__y(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector__z(a3dp_SPAunit_vector *self); -PyObject *a3dp_SPAunitvector_x_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAunitvector_y_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -PyObject *a3dp_SPAunitvector_z_getter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -int a3dp_SPAunitvector_x_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -int a3dp_SPAunitvector_y_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); -int a3dp_SPAunitvector_z_setter(a3dp_SPAunit_vector *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAunit_vector[] = - { - { (char *) "x_value", (getter) a3dp_SPAunitvector_x_getter, (setter) a3dp_SPAunitvector_x_setter, (char *) "value of the x component", NULL }, - { (char *) "y_value", (getter) a3dp_SPAunitvector_y_getter, (setter) a3dp_SPAunitvector_y_setter, (char *) "value of the y component", NULL }, - { (char *) "z_value", (getter) a3dp_SPAunitvector_z_getter, (setter) a3dp_SPAunitvector_z_setter, (char *) "value of the z component", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_SPAunit_vector[] = - { - { "component", (PyCFunction) a3dp_SPAunitvector__component, METH_O, "Returns the i-th component of the vector" }, - { "set_component", (PyCFunction) a3dp_SPAunitvector__set_component, METH_VARARGS | METH_KEYWORDS, "Sets the i-th component of the vector" }, - { "set_x", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the x-component of the vector" }, - { "set_y", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the y-component of the vector" }, - { "set_z", (PyCFunction) a3dp_SPAunitvector__set_x, METH_O, "Sets the z-component of the vector" }, - { "x", (PyCFunction) a3dp_SPAunitvector__x, METH_NOARGS, "Returns the x-component of the vector" }, - { "y", (PyCFunction) a3dp_SPAunitvector__y, METH_NOARGS, "Returns the y-component of the vector" }, - { "z", (PyCFunction) a3dp_SPAunitvector__z, METH_NOARGS, "Returns the z-component of the vector" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAunitvector = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAunit_vector", /* tp_name */ - sizeof(a3dp_SPAunit_vector), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAunitvector_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAunitvector_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAunitvector_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAunit_vector provides a direction in 3D Cartesian space that has unit length", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAunit_vector, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAunit_vector, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAunitvector_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAunitvector_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAunit_vector(); - -bool _PyCheck_SPAunit_vector(PyObject *ob); - // Define SPAmatrix typedef struct { @@ -319,79 +47,6 @@ typedef struct SPAmatrix *_acis_obj; } a3dp_SPAmatrix; -void a3dp_SPAmatrix_dealloc(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAmatrix_init(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAmatrix__column(a3dp_SPAmatrix *self, PyObject *arg); -PyObject *a3dp_SPAmatrix__row(a3dp_SPAmatrix *self, PyObject *arg); -PyObject *a3dp_SPAmatrix__inverse(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix__transpose(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix__determinant(a3dp_SPAmatrix *self); -PyObject *a3dp_SPAmatrix__element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAmatrix__set_element(a3dp_SPAmatrix *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAmatrix__is_identity(a3dp_SPAmatrix *self); - -static PyMethodDef - a3dp_methods_SPAmatrix[] = - { - { "column", (PyCFunction) a3dp_SPAmatrix__column, METH_O, "Extracts a column from this matrix" }, - { "row", (PyCFunction) a3dp_SPAmatrix__row, METH_O, "Extracts a row from this matrix" }, - { "element", (PyCFunction) a3dp_SPAmatrix__element, METH_VARARGS | METH_KEYWORDS, "Extracts an element of this matrix" }, - { "set_element", (PyCFunction) a3dp_SPAmatrix__set_element, METH_VARARGS | METH_KEYWORDS, "Assigns a value to an element in the matrix" }, - { "determinant", (PyCFunction) a3dp_SPAmatrix__determinant, METH_NOARGS, "Returns the determinant of this matrix" }, - { "transpose", (PyCFunction) a3dp_SPAmatrix__transpose, METH_NOARGS, "Returns a transpose of this matrix" }, - { "inverse", (PyCFunction) a3dp_SPAmatrix__inverse, METH_NOARGS, "Returns the inverse of this matrix" }, - { "is_identity", (PyCFunction) a3dp_SPAmatrix__is_identity, METH_NOARGS, "Returns TRUE if this matrix is the identity matrix" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAmatrix = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAmatrix", /* tp_name */ - sizeof(a3dp_SPAmatrix), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAmatrix_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAmatrix defines a 3x3 affine transformation acting on vectors and positions", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAmatrix, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAmatrix_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAmatrix_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAmatrix(); - -bool _PyCheck_SPAmatrix(PyObject *ob); - // Define SPAtransf typedef struct { @@ -399,79 +54,6 @@ typedef struct SPAtransf *_acis_obj; } a3dp_SPAtransf; -void a3dp_SPAtransf_dealloc(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAtransf_init(a3dp_SPAtransf *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAtransf__affine(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__inverse(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__translation(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__identity(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__reflect(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__rotate(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__scaling(a3dp_SPAtransf *self); -PyObject *a3dp_SPAtransf__shear(a3dp_SPAtransf *self); - -static PyMethodDef - a3dp_methods_SPAtransf[] = - { - { "affine", (PyCFunction) a3dp_SPAtransf__affine, METH_NOARGS, "Returns the affine portion of the transformation" }, - { "inverse", (PyCFunction) a3dp_SPAtransf__inverse, METH_NOARGS, "Returns the inverse transformation" }, - { "translation", (PyCFunction) a3dp_SPAtransf__translation, METH_NOARGS, "Returns the vector representing the translational portion of the transformation" }, - { "identity", (PyCFunction) a3dp_SPAtransf__identity, METH_NOARGS, "Queries whether or not the transformation is the identity" }, - { "reflect", (PyCFunction) a3dp_SPAtransf__reflect, METH_NOARGS, "Queries whether or not the transformation is reflecting" }, - { "rotate", (PyCFunction) a3dp_SPAtransf__rotate, METH_NOARGS, "Queries whether or not the transformation has a rotational component" }, - { "scaling", (PyCFunction) a3dp_SPAtransf__scaling, METH_NOARGS, "Returns the scaling factor of the transformation" }, - { "shear", (PyCFunction) a3dp_SPAtransf__shear, METH_NOARGS, "Queries whether or not the transformation has a shearing component" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAtransf = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(a3dp_SPAtransf), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAtransf_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPAtransf represents a general 3D affine transformation", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SPAtransf, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAtransf_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAtransf_new, /* tp_new */ - }; - -PyObject *_PyNew_SPAtransf(); - -bool _PyCheck_SPAtransf(PyObject *ob); - // Define SPApar_pos typedef struct { @@ -479,70 +61,6 @@ typedef struct SPApar_pos *_acis_obj; } a3dp_SPApar_pos; -void a3dp_SPAparpos_dealloc(a3dp_SPApar_pos *self); -PyObject *a3dp_SPAparpos_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAparpos_init(a3dp_SPApar_pos *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAparpos_repr(a3dp_SPApar_pos *self); -PyObject *a3dp_SPAparpos_u_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); -int a3dp_SPAparpos_u_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); -PyObject *a3dp_SPAparpos_v_getter(a3dp_SPApar_pos *self, PyObject *value, void *closure); -int a3dp_SPAparpos_v_setter(a3dp_SPApar_pos *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAparpos[] = - { - { (char *) "u", (getter) a3dp_SPAparpos_u_getter, (setter) a3dp_SPAparpos_u_setter, (char *) "value of the u parameter", NULL }, - { (char *) "v", (getter) a3dp_SPAparpos_v_getter, (setter) a3dp_SPAparpos_v_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAparpos = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPAtransf", /* tp_name */ - sizeof(a3dp_SPApar_pos), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAparpos_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAparpos_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAparpos_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_pos defines a parameter position in the parameter-space of a surface", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAparpos, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAparpos_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAparpos_new, /* tp_new */ - }; - -PyObject *_PyNew_SPApar_pos(); - -bool _PyCheck_SPApar_pos(PyObject *ob); - // Define SPApar_vec typedef struct { @@ -550,70 +68,6 @@ typedef struct SPApar_vec *_acis_obj; } a3dp_SPApar_vec; -void a3dp_SPAparvec_dealloc(a3dp_SPApar_vec *self); -PyObject *a3dp_SPAparvec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_SPAparvec_init(a3dp_SPApar_vec *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPAparvec_repr(a3dp_SPApar_vec *self); -PyObject *a3dp_SPAparvec_du_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); -int a3dp_SPAparvec_du_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); -PyObject *a3dp_SPAparvec_dv_getter(a3dp_SPApar_vec *self, PyObject *value, void *closure); -int a3dp_SPAparvec_dv_setter(a3dp_SPApar_vec *self, PyObject *value, void *closure); - -static PyGetSetDef - a3dp_getseters_SPAparvec[] = - { - { (char *) "du", (getter) a3dp_SPAparvec_du_getter, (setter) a3dp_SPAparvec_du_setter, (char *) "value of the u parameter", NULL }, - { (char *) "dv", (getter) a3dp_SPAparvec_dv_getter, (setter) a3dp_SPAparvec_dv_setter, (char *) "value of the v parameter", NULL }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SPAparvec = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPApar_vec", /* tp_name */ - sizeof(a3dp_SPApar_vec), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_SPAparvec_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPAparvec_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPAparvec_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "SPApar_vec defines a vector (du, dv) in 2D parameter-space", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_SPAparvec, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPAparvec_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_SPAparvec_new, /* tp_new */ - }; - -PyObject *_PyNew_SPApar_vec(); - -bool _PyCheck_SPApar_vec(PyObject *ob); - // Define FileInfo typedef struct { @@ -621,215 +75,60 @@ typedef struct FileInfo *_acis_obj; } a3dp_FileInfo; -void a3dp_FileInfo_dealloc(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_FileInfo_init(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__acis_version(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__date(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__file_version(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__product_id(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__reset(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__reset_vars(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__restore(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__save(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__set_masked(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__set_product_id(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__set_units(a3dp_FileInfo *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FileInfo__tol_abs(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__tol_nor(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__units(a3dp_FileInfo *self); -PyObject *a3dp_FileInfo__valid(a3dp_FileInfo *self); +// Define sweep_options +typedef struct +{ + PyObject_HEAD + sweep_options *_acis_obj; +} a3dp_sweep_options; -static PyMemberDef - a3dp_members_FileInfo[] = - { - { NULL } /* Sentinel */ - }; +// Define make_sweep_path_options +typedef struct +{ + PyObject_HEAD + make_sweep_path_options *_acis_obj; +} a3dp_make_sweep_path_options; -static PyMethodDef - a3dp_methods_FileInfo[] = - { - { "acis_version", (PyCFunction) a3dp_FileInfo__acis_version, METH_NOARGS, "Returns the ACIS version number used to save the model" }, - { "date", (PyCFunction) a3dp_FileInfo__date, METH_NOARGS, "Returns the date on the save file" }, - { "file_version", (PyCFunction) a3dp_FileInfo__file_version, METH_NOARGS, "Returns the save file version used in storing the file" }, - { "product_id", (PyCFunction) a3dp_FileInfo__product_id, METH_NOARGS, "Returns the ID of the product" }, - { "reset", (PyCFunction) a3dp_FileInfo__reset, METH_NOARGS, "Resets the values to the default settings for the file information" }, - { "reset_vars", (PyCFunction) a3dp_FileInfo__reset_vars, METH_NOARGS, "Routine to reset the values for the file information to the default values" }, - { "restore", (PyCFunction) a3dp_FileInfo__restore, METH_NOARGS, "Restores the file information from a save file" }, - { "save", (PyCFunction) a3dp_FileInfo__save, METH_NOARGS, "Saves the product ID, version, time, units, SPAresabs and SPAresnor" }, - //{ "set_masked", (PyCFunction)a3dp_FileInfo__set_masked, METH_VARARGS | METH_KEYWORDS, "Copies selected fields from another instance" }, - { "set_product_id", (PyCFunction) a3dp_FileInfo__set_product_id, METH_VARARGS | METH_KEYWORDS, "Sets the product ID" }, - { "set_units", (PyCFunction) a3dp_FileInfo__set_units, METH_VARARGS | METH_KEYWORDS, "Sets the model units scale (in millimeters)" }, - { "tol_abs", (PyCFunction) a3dp_FileInfo__tol_abs, METH_NOARGS, "Returns the value of the SPAresabs when the model was saved" }, - { "tol_nor", (PyCFunction) a3dp_FileInfo__tol_nor, METH_NOARGS, "Returns the value of the SPAresnor when the model was saved" }, - { "units", (PyCFunction) a3dp_FileInfo__units, METH_NOARGS, "Returns the value of the millimeters per model unit" }, - { "valid", (PyCFunction) a3dp_FileInfo__valid, METH_NOARGS, "Checks the values of the units and product id" }, - { NULL } /* Sentinel */ - }; +extern PyTypeObject a3dp_type_SPAposition; +extern PyTypeObject a3dp_type_SPAvector; +extern PyTypeObject a3dp_type_SPAunit_vector; +extern PyTypeObject a3dp_type_SPAmatrix; +extern PyTypeObject a3dp_type_SPAtransf; +extern PyTypeObject a3dp_type_SPApar_pos; +extern PyTypeObject a3dp_type_SPApar_vec; +extern PyTypeObject a3dp_type_FileInfo; +extern PyTypeObject a3dp_type_sweep_options; +extern PyTypeObject a3dp_type_make_sweep_path_options; -static PyTypeObject - a3dp_type_FileInfo = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FileInfo", /* tp_name */ - sizeof(a3dp_FileInfo), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_FileInfo_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "FileInfo object contains additional required save file header information", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_FileInfo, /* tp_methods */ - a3dp_members_FileInfo, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_FileInfo_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_FileInfo_new, /* tp_new */ - }; +#ifdef __cplusplus +extern "C" { +#endif -bool _PyCheck_FileInfo(PyObject *ob); +PyObject *_PyNew_SPAposition(); +bool _PyCheck_SPAposition(PyObject *ob); -// Define sweep_options -typedef struct -{ - PyObject_HEAD - sweep_options *_acis_obj; -} a3dp_sweep_options; +PyObject *_PyNew_SPAvector(); +bool _PyCheck_SPAvector(PyObject *ob); -void a3dp_sweepoptions_dealloc(a3dp_sweep_options *self); -PyObject *a3dp_sweepoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_sweepoptions_init(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_sweepoptions__set_bool_type(a3dp_sweep_options *self, PyObject *args, PyObject *kwargs); +PyObject *_PyNew_SPAunit_vector(); +bool _PyCheck_SPAunit_vector(PyObject *ob); -static PyMethodDef - a3dp_methods_sweepoptions[] = - { - { "set_bool_type", (PyCFunction) a3dp_sweepoptions__set_bool_type, METH_VARARGS | METH_KEYWORDS, "Sets the option for the Boolean operation type with the to_body" }, - { NULL } /* Sentinel */ - }; +PyObject *_PyNew_SPAmatrix(); +bool _PyCheck_SPAmatrix(PyObject *ob); -static PyTypeObject - a3dp_type_sweep_options = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_options", /* tp_name */ - sizeof(a3dp_sweep_options), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_sweepoptions_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "sweep_options class provides a data structure for sweeping operations to be used in the function api_sweep_with_options", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_sweepoptions, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_sweepoptions_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_sweepoptions_new, /* tp_new */ - }; +PyObject *_PyNew_SPAtransf(); +bool _PyCheck_SPAtransf(PyObject *ob); -PyObject *_PyNew_sweep_options(); -bool _PyCheck_sweep_options(PyObject *ob); +PyObject *_PyNew_SPApar_pos(); +bool _PyCheck_SPApar_pos(PyObject *ob); -// Define make_sweep_path_options -typedef struct -{ - PyObject_HEAD - make_sweep_path_options *_acis_obj; -} a3dp_make_sweep_path_options; +PyObject *_PyNew_SPApar_vec(); +bool _PyCheck_SPApar_vec(PyObject *ob); -void a3dp_makesweeppathoptions_dealloc(a3dp_make_sweep_path_options *self); -PyObject *a3dp_makesweeppathoptions_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_makesweeppathoptions_init(a3dp_make_sweep_path_options *self, PyObject *args, PyObject *kwargs); +bool _PyCheck_FileInfo(PyObject *ob); -static PyTypeObject - a3dp_type_make_sweep_path_options = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.make_sweep_path_options", /* tp_name */ - sizeof(a3dp_make_sweep_path_options), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_makesweeppathoptions_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "make_sweep_path_options class allows the user to exercise finer control over the construction of sweep path", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_makesweeppathoptions_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_makesweeppathoptions_new, /* tp_new */ - }; +PyObject *_PyNew_sweep_options(); +bool _PyCheck_sweep_options(PyObject *ob); PyObject *_PyNew_make_sweep_path_options(); bool _PyCheck_make_sweep_path_options(PyObject *ob); diff --git a/src/acis_entity.cpp b/src/acis_entity.cpp index e9f61a5..b181951 100644 --- a/src/acis_entity.cpp +++ b/src/acis_entity.cpp @@ -5,7 +5,7 @@ * ENTITY class */ -int +static int a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg) { // Use Py_VISIT macro for PyObject-type variables @@ -15,7 +15,7 @@ a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg) return 0; } -int +static int a3dp_ENTITY_clear(a3dp_ENTITY *self) { // Set ACIS object to NULL to allow it automatically deleted by ACIS memory manager @@ -28,14 +28,14 @@ a3dp_ENTITY_clear(a3dp_ENTITY *self) return 0; } -void +static void a3dp_ENTITY_dealloc(a3dp_ENTITY *self) { a3dp_ENTITY_clear(self); Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started @@ -71,7 +71,7 @@ a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs) { // PyObject *input_name = NULL; @@ -127,7 +127,7 @@ a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_ENTITY_repr(a3dp_ENTITY *self) { const char *_name = PyUnicode_AsUTF8(self->attrib_name); @@ -135,7 +135,7 @@ a3dp_ENTITY_repr(a3dp_ENTITY *self) return PyUnicode_FromFormat("ENTITY object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_ENTITY_str(a3dp_ENTITY *self) { const char *acis_obj_status = NULL; @@ -147,14 +147,14 @@ a3dp_ENTITY_str(a3dp_ENTITY *self) return PyUnicode_FromFormat("ENTITY object (%s)", acis_obj_status); } -PyObject * +static PyObject * a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_name); return self->attrib_name; } -int +static int a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) @@ -187,21 +187,21 @@ a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure) return 0; } -PyObject * +static PyObject * a3dp_ENTITY_type_name(PyObject *self) { const char *_retval = ((a3dp_ENTITY *)self)->_acis_obj->type_name(); return PyUnicode_FromString(_retval); } -PyObject * +static PyObject * a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) { Py_INCREF(self->attrib_object_id); return self->attrib_object_id; } -int +static int a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) { if (value == NULL) @@ -237,12 +237,84 @@ a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure) return 0; } +static PyGetSetDef + a3dp_getseters_ENTITY[] = + { + { (char *) "name", (getter) a3dp_ENTITY_get_attrib_name, (setter) a3dp_ENTITY_set_attrib_name, (char *) "object name", NULL }, + { (char *) "id", (getter) a3dp_ENTITY_get_attrib_obj_id, (setter) a3dp_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, + { NULL } /* Sentinel */ + }; + +static PyMethodDef + a3dp_methods_ENTITY[] = + { + { "type_name", (PyCFunction) a3dp_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_ENTITY = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.ENTITY", /* tp_name */ + sizeof(a3dp_ENTITY), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_ENTITY_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_ENTITY_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_ENTITY_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC, /* tp_flags */ + "ACIS ENTITY class", /* tp_doc */ + (traverseproc) a3dp_ENTITY_traverse, /* tp_traverse */ + (inquiry) a3dp_ENTITY_clear, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_ENTITY, /* tp_methods */ + 0, /* tp_members */ + a3dp_getseters_ENTITY, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_ENTITY_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_ENTITY_new, /* tp_new */ + }; + +PyObject * +_PyNew_ENTITY() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_ENTITY, NULL); +} + +bool +_PyCheck_ENTITY(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_ENTITY); +} + /** * BODY class */ -int +static int a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -252,7 +324,7 @@ a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_BODY_repr(a3dp_BODY *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -260,7 +332,7 @@ a3dp_BODY_repr(a3dp_BODY *self) return PyUnicode_FromFormat("BODY object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_BODY_str(a3dp_BODY *self) { const char *acis_obj_status = NULL; @@ -272,12 +344,67 @@ a3dp_BODY_str(a3dp_BODY *self) return PyUnicode_FromFormat("BODY object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_BODY = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.BODY", /* tp_name */ + sizeof(a3dp_BODY), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_BODY_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_BODY_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS BODY class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_BODY_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject * +_PyNew_BODY() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_BODY, NULL); +} + +bool +_PyCheck_BODY(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_BODY); +} + /** * FACE class */ -int +static int a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -287,7 +414,7 @@ a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_FACE_repr(a3dp_FACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -295,7 +422,7 @@ a3dp_FACE_repr(a3dp_FACE *self) return PyUnicode_FromFormat("FACE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_FACE_str(a3dp_FACE *self) { const char *acis_obj_status = NULL; @@ -307,7 +434,7 @@ a3dp_FACE_str(a3dp_FACE *self) return PyUnicode_FromFormat("FACE object (%s)", acis_obj_status); } -PyObject * +static PyObject * a3dp_FACE__sense(a3dp_FACE *self) { logical _revbit; @@ -320,7 +447,7 @@ a3dp_FACE__sense(a3dp_FACE *self) Py_RETURN_FALSE; } -PyObject * +static PyObject * a3dp_FACE__geometry(a3dp_FACE *self) { PyObject *_retobj = _PyNew_SURFACE(); @@ -329,12 +456,73 @@ a3dp_FACE__geometry(a3dp_FACE *self) return _retobj; } +static PyMethodDef + a3dp_methods_FACE[] = + { + { "sense", (PyCFunction) a3dp_FACE__sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, + { "geometry", (PyCFunction) a3dp_FACE__geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_FACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.FACE", /* tp_name */ + sizeof(a3dp_FACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_FACE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_FACE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS FACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_FACE, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_FACE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_FACE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_FACE, NULL); +} + +bool _PyCheck_FACE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_FACE); +} + /** * EDGE class */ -int +static int a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -344,7 +532,7 @@ a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_EDGE_repr(a3dp_EDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -352,7 +540,7 @@ a3dp_EDGE_repr(a3dp_EDGE *self) return PyUnicode_FromFormat("EDGE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_EDGE_str(a3dp_EDGE *self) { const char *acis_obj_status = NULL; @@ -364,12 +552,65 @@ a3dp_EDGE_str(a3dp_EDGE *self) return PyUnicode_FromFormat("EDGE object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_EDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.EDGE", /* tp_name */ + sizeof(a3dp_EDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_EDGE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_EDGE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS EDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_EDGE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_EDGE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_EDGE, NULL); +} + +bool _PyCheck_EDGE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_EDGE); +} + /** * WIRE class */ -int +static int a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -379,7 +620,7 @@ a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_WIRE_repr(a3dp_WIRE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -387,7 +628,7 @@ a3dp_WIRE_repr(a3dp_WIRE *self) return PyUnicode_FromFormat("WIRE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_WIRE_str(a3dp_WIRE *self) { const char *acis_obj_status = NULL; @@ -399,11 +640,65 @@ a3dp_WIRE_str(a3dp_WIRE *self) return PyUnicode_FromFormat("WIRE object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_WIRE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.WIRE", /* tp_name */ + sizeof(a3dp_WIRE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_WIRE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_WIRE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS WIRE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_WIRE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_WIRE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_WIRE, NULL); +} + +bool _PyCheck_WIRE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_WIRE); +} + + /** * LUMP class */ -int +static int a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -413,7 +708,7 @@ a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_LUMP_repr(a3dp_LUMP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -421,7 +716,7 @@ a3dp_LUMP_repr(a3dp_LUMP *self) return PyUnicode_FromFormat("LUMP object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_LUMP_str(a3dp_LUMP *self) { const char *acis_obj_status = NULL; @@ -433,11 +728,65 @@ a3dp_LUMP_str(a3dp_LUMP *self) return PyUnicode_FromFormat("LUMP object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_LUMP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LUMP", /* tp_name */ + sizeof(a3dp_LUMP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_LUMP_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_LUMP_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LUMP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_LUMP_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_LUMP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_LUMP, NULL); +} + +bool _PyCheck_LUMP(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_LUMP); +} + + /** * SHELL class */ -int +static int a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -447,7 +796,7 @@ a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SHELL_repr(a3dp_SHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -455,7 +804,7 @@ a3dp_SHELL_repr(a3dp_SHELL *self) return PyUnicode_FromFormat("SHELL object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_SHELL_str(a3dp_SHELL *self) { const char *acis_obj_status = NULL; @@ -467,11 +816,65 @@ a3dp_SHELL_str(a3dp_SHELL *self) return PyUnicode_FromFormat("SHELL object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_SHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SHELL", /* tp_name */ + sizeof(a3dp_SHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SHELL_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SHELL_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SHELL_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SHELL() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SHELL, NULL); +} + +bool _PyCheck_SHELL(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_SHELL); +} + + /** * SUBSHELL class */ -int +static int a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -481,7 +884,7 @@ a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -489,7 +892,7 @@ a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self) return PyUnicode_FromFormat("SUBSHELL object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_SUBSHELL_str(a3dp_SUBSHELL *self) { const char *acis_obj_status = NULL; @@ -501,11 +904,65 @@ a3dp_SUBSHELL_str(a3dp_SUBSHELL *self) return PyUnicode_FromFormat("SUBSHELL object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_SUBSHELL = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SUBSHELL", /* tp_name */ + sizeof(a3dp_SUBSHELL), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SUBSHELL_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SUBSHELL_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SUBSHELL class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SUBSHELL_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SUBSHELL() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SUBSHELL, NULL); +} + +bool _PyCheck_SUBSHELL(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_SUBSHELL); +} + + /** * COEDGE class */ -int +static int a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -515,7 +972,7 @@ a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_COEDGE_repr(a3dp_COEDGE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -523,7 +980,7 @@ a3dp_COEDGE_repr(a3dp_COEDGE *self) return PyUnicode_FromFormat("COEDGE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_COEDGE_str(a3dp_COEDGE *self) { const char *acis_obj_status = NULL; @@ -535,12 +992,65 @@ a3dp_COEDGE_str(a3dp_COEDGE *self) return PyUnicode_FromFormat("COEDGE object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_COEDGE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.COEDGE", /* tp_name */ + sizeof(a3dp_COEDGE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_COEDGE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_COEDGE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS COEDGE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_COEDGE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_COEDGE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_COEDGE, NULL); +} + +bool _PyCheck_COEDGE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_COEDGE); +} + /** * LOOP class */ -int +static int a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -550,7 +1060,7 @@ a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_LOOP_repr(a3dp_LOOP *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -558,7 +1068,7 @@ a3dp_LOOP_repr(a3dp_LOOP *self) return PyUnicode_FromFormat("LOOP object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_LOOP_str(a3dp_LOOP *self) { const char *acis_obj_status = NULL; @@ -570,11 +1080,66 @@ a3dp_LOOP_str(a3dp_LOOP *self) return PyUnicode_FromFormat("LOOP object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_LOOP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.LOOP", /* tp_name */ + sizeof(a3dp_LOOP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_LOOP_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_LOOP_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS LOOP class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_LOOP_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + +PyObject *_PyNew_LOOP() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_LOOP, NULL); +} + +bool _PyCheck_LOOP(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_LOOP); +} + + /** * VERTEX class */ -int +static int a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -584,7 +1149,7 @@ a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_VERTEX_repr(a3dp_VERTEX *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -592,7 +1157,7 @@ a3dp_VERTEX_repr(a3dp_VERTEX *self) return PyUnicode_FromFormat("VERTEX object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_VERTEX_str(a3dp_VERTEX *self) { const char *acis_obj_status = NULL; @@ -604,11 +1169,65 @@ a3dp_VERTEX_str(a3dp_VERTEX *self) return PyUnicode_FromFormat("VERTEX object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_VERTEX = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.VERTEX", /* tp_name */ + sizeof(a3dp_VERTEX), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_VERTEX_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_VERTEX_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS VERTEX class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_VERTEX_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_VERTEX() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_VERTEX, NULL); +} + +bool _PyCheck_VERTEX(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_VERTEX); +} + + /** * SURFACE class */ -int +static int a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -618,7 +1237,7 @@ a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SURFACE_repr(a3dp_SURFACE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -626,7 +1245,7 @@ a3dp_SURFACE_repr(a3dp_SURFACE *self) return PyUnicode_FromFormat("SURFACE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_SURFACE_str(a3dp_SURFACE *self) { const char *acis_obj_status = NULL; @@ -638,7 +1257,7 @@ a3dp_SURFACE_str(a3dp_SURFACE *self) return PyUnicode_FromFormat("SURFACE object (%s)", acis_obj_status); } -PyObject * +static PyObject * a3dp_SURFACE__equation(a3dp_SURFACE *self) { PyObject *_retobj = _PyNew_surface(); @@ -646,7 +1265,7 @@ a3dp_SURFACE__equation(a3dp_SURFACE *self) return _retobj; } -PyObject * +static PyObject * a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs) { PyObject *input_t = NULL, *input_reverse = NULL; @@ -688,11 +1307,74 @@ a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs return _retobj; } +static PyMethodDef + a3dp_methods_SURFACE[] = + { + { "equation", (PyCFunction) a3dp_SURFACE__equation, METH_NOARGS, "Returns the equation of this SURFACE" }, + { "trans_surface", (PyCFunction) a3dp_SURFACE__trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_SURFACE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SURFACE", /* tp_name */ + sizeof(a3dp_SURFACE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SURFACE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SURFACE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SURFACE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_SURFACE, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SURFACE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + +PyObject *_PyNew_SURFACE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SURFACE, NULL); +} + +bool _PyCheck_SURFACE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_SURFACE); +} + + /** * CONE class */ -int +static int a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -702,7 +1384,7 @@ a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_CONE_repr(a3dp_CONE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -710,7 +1392,7 @@ a3dp_CONE_repr(a3dp_CONE *self) return PyUnicode_FromFormat("CONE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_CONE_str(a3dp_CONE *self) { const char *acis_obj_status = NULL; @@ -722,11 +1404,66 @@ a3dp_CONE_str(a3dp_CONE *self) return PyUnicode_FromFormat("CONE object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_CONE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.CONE", /* tp_name */ + sizeof(a3dp_CONE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_CONE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_CONE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS CONE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_CONE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + + +PyObject *_PyNew_CONE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_CONE, NULL); +} + +bool _PyCheck_CONE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_CONE); +} + + /** * PLANE class */ -int +static int a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -736,7 +1473,7 @@ a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_PLANE_repr(a3dp_PLANE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -744,7 +1481,7 @@ a3dp_PLANE_repr(a3dp_PLANE *self) return PyUnicode_FromFormat("PLANE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_PLANE_str(a3dp_PLANE *self) { const char *acis_obj_status = NULL; @@ -756,11 +1493,65 @@ a3dp_PLANE_str(a3dp_PLANE *self) return PyUnicode_FromFormat("PLANE object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_PLANE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.PLANE", /* tp_name */ + sizeof(a3dp_PLANE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_PLANE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_PLANE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS PLANE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_PLANE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_PLANE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_PLANE, NULL); +} + +bool _PyCheck_PLANE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_PLANE); +} + + /** * SPHERE class */ -int +static int a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -770,7 +1561,7 @@ a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPHERE_repr(a3dp_SPHERE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -778,7 +1569,7 @@ a3dp_SPHERE_repr(a3dp_SPHERE *self) return PyUnicode_FromFormat("SPHERE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_SPHERE_str(a3dp_SPHERE *self) { const char *acis_obj_status = NULL; @@ -790,11 +1581,65 @@ a3dp_SPHERE_str(a3dp_SPHERE *self) return PyUnicode_FromFormat("SPHERE object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_SPHERE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPHERE", /* tp_name */ + sizeof(a3dp_SPHERE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPHERE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPHERE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPHERE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPHERE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SPHERE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPHERE, NULL); +} + +bool _PyCheck_SPHERE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_SPHERE); +} + + /** * SPLINE class */ -int +static int a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -804,7 +1649,7 @@ a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_SPLINE_repr(a3dp_SPLINE *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -812,7 +1657,7 @@ a3dp_SPLINE_repr(a3dp_SPLINE *self) return PyUnicode_FromFormat("SPLINE object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_SPLINE_str(a3dp_SPLINE *self) { const char *acis_obj_status = NULL; @@ -824,11 +1669,65 @@ a3dp_SPLINE_str(a3dp_SPLINE *self) return PyUnicode_FromFormat("SPLINE object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_SPLINE = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.SPLINE", /* tp_name */ + sizeof(a3dp_SPLINE), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_SPLINE_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_SPLINE_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS SPLINE class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_SPLINE_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_SPLINE() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_SPLINE, NULL); +} + +bool _PyCheck_SPLINE(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_SPLINE); +} + + /** * TORUS class */ -int +static int a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs) { // Initialize the base class @@ -838,7 +1737,7 @@ a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs) return 0; } -PyObject * +static PyObject * a3dp_TORUS_repr(a3dp_TORUS *self) { const char *_name = PyUnicode_AsUTF8(self->base_obj.attrib_name); @@ -846,7 +1745,7 @@ a3dp_TORUS_repr(a3dp_TORUS *self) return PyUnicode_FromFormat("TORUS object with name '%s' and ID '%i'", _name, _id); } -PyObject * +static PyObject * a3dp_TORUS_str(a3dp_TORUS *self) { const char *acis_obj_status = NULL; @@ -858,17 +1757,71 @@ a3dp_TORUS_str(a3dp_TORUS *self) return PyUnicode_FromFormat("TORUS object (%s)", acis_obj_status); } +PyTypeObject + a3dp_type_TORUS = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.TORUS", /* tp_name */ + sizeof(a3dp_TORUS), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc) a3dp_TORUS_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) a3dp_TORUS_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS TORUS class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_TORUS_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + }; + +PyObject *_PyNew_TORUS() +{ + return PyObject_CallObject((PyObject *) &a3dp_type_TORUS, NULL); +} + +bool _PyCheck_TORUS(PyObject *ob) +{ + return PyObject_TypeCheck(ob, &a3dp_type_TORUS); +} + + /** * surface class */ -void +static void a3dp_surface_dealloc(a3dp_surface *self) { Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { // First check if the modeler has been started @@ -890,13 +1843,13 @@ a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs) { return 0; } -PyObject * +static PyObject * a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg) { if (!_PyCheck_SPApar_pos(arg)) @@ -919,7 +1872,7 @@ a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg) return _retobj; } -PyObject * +static PyObject * a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg) { if (!_PyCheck_SPApar_pos(arg)) @@ -942,181 +1895,56 @@ a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg) return _retobj; } -PyObject *_PyNew_ENTITY() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_ENTITY, NULL); -} - -bool _PyCheck_ENTITY(PyObject *ob) -{ - int retval = PyObject_IsInstance(ob, (PyObject *) &a3dp_type_ENTITY); - if (retval < 0) +static PyMethodDef + a3dp_methods_surface[] = { - PyErr_SetString(PyExc_TypeError, "Problem with ENTITY type cheking"); - return false; - } - return retval != 0; -} - -PyObject *_PyNew_BODY() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_BODY, NULL); -} - -bool _PyCheck_BODY(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_BODY; -} - -PyObject *_PyNew_FACE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_FACE, NULL); -} - -bool _PyCheck_FACE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_FACE; -} - -PyObject *_PyNew_EDGE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_EDGE, NULL); -} - -bool _PyCheck_EDGE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_EDGE; -} - -PyObject *_PyNew_WIRE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_WIRE, NULL); -} - -bool _PyCheck_WIRE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_WIRE; -} - -PyObject *_PyNew_LUMP() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_LUMP, NULL); -} - -bool _PyCheck_LUMP(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_LUMP; -} - -PyObject *_PyNew_SHELL() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SHELL, NULL); -} - -bool _PyCheck_SHELL(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SHELL; -} - -PyObject *_PyNew_SUBSHELL() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SUBSHELL, NULL); -} - -bool _PyCheck_SUBSHELL(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SUBSHELL; -} - -PyObject *_PyNew_COEDGE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_COEDGE, NULL); -} - -bool _PyCheck_COEDGE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_COEDGE; -} - -PyObject *_PyNew_LOOP() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_LOOP, NULL); -} + { "eval_normal", (PyCFunction) a3dp_surface__eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, + { "eval_position", (PyCFunction) a3dp_surface__eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, + { NULL } /* Sentinel */ + }; -bool _PyCheck_LOOP(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_LOOP; -} - -PyObject *_PyNew_VERTEX() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_VERTEX, NULL); -} - -bool _PyCheck_VERTEX(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_VERTEX; -} - -PyObject *_PyNew_SURFACE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SURFACE, NULL); -} - -bool _PyCheck_SURFACE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SURFACE; -} - -PyObject *_PyNew_CONE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_CONE, NULL); -} - -bool _PyCheck_CONE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_CONE; -} - -PyObject *_PyNew_PLANE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_PLANE, NULL); -} - -bool _PyCheck_PLANE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_PLANE; -} - -PyObject *_PyNew_SPHERE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPHERE, NULL); -} - -bool _PyCheck_SPHERE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPHERE; -} - -PyObject *_PyNew_SPLINE() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_SPLINE, NULL); -} - -bool _PyCheck_SPLINE(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_SPLINE; -} - -PyObject *_PyNew_TORUS() -{ - return PyObject_CallObject((PyObject *) &a3dp_type_TORUS, NULL); -} - -bool _PyCheck_TORUS(PyObject *ob) -{ - return Py_TYPE(ob) == &a3dp_type_TORUS; -} +PyTypeObject + a3dp_type_surface = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.surface", /* tp_name */ + sizeof(a3dp_surface), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_surface_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS surface class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + a3dp_methods_surface, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_surface_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_surface_new, /* tp_new */ + }; PyObject *_PyNew_surface() { @@ -1125,27 +1953,15 @@ PyObject *_PyNew_surface() bool _PyCheck_surface(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_surface; -} - -void _a3dp_make_null(PyObject *ob) -{ - if (_PyCheck_ENTITY(ob)) - { - ((a3dp_ENTITY *) ob)->_acis_obj = NULL; - } + return PyObject_TypeCheck(ob, &a3dp_type_surface); } -void _a3dp_set_entity(PyObject *ob, ENTITY *ent) -{ - ((a3dp_ENTITY *)ob)->_acis_obj = ent; -} /** * ENTITY_LIST class */ -void +static void a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self) { // First, clear the contents of the ENTITY_LIST instance @@ -1158,7 +1974,7 @@ a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self) Py_TYPE(self)->tp_free((PyObject *) self); } -PyObject * +static PyObject * a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { a3dp_ENTITY_LIST *self; @@ -1173,7 +1989,7 @@ a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *) self; } -int +static int a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self) { // ENTITY_LIST takes no arguments, so parsing is necessary @@ -1181,21 +1997,21 @@ a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self) return 0; } -PyObject * +static PyObject * a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self) { self->_acis_obj->init(); Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self) { self->_acis_obj->clear(); Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -1236,7 +2052,7 @@ a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg) } } -PyObject * +static PyObject * a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -1285,26 +2101,26 @@ a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg) } } -PyObject * +static PyObject * a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self) { return PyLong_FromLong(self->_acis_obj->count()); } -PyObject * +static PyObject * a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self) { return PyLong_FromLong(self->_acis_obj->iteration_count()); } -PyObject * +static PyObject * a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self) { self->_acis_obj->reverse(); Py_RETURN_NONE; } -PyObject * +static PyObject * a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg) { // Treat arg as a borrowed reference @@ -1325,13 +2141,13 @@ a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg) return PyLong_FromLong(index); } -PyObject * +static PyObject * a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self) { return PyLong_FromLong(self->_acis_obj->byte_count()); } -PyObject * +static PyObject * a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self) { ENTITY *_elem = self->_acis_obj->first(); @@ -1339,7 +2155,7 @@ a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self) return retobj; } -PyObject * +static PyObject * a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self) { PyObject *retobj; @@ -1359,7 +2175,7 @@ a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self) return retobj; } -PyObject * +static PyObject * a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg) { if (!PyLong_Check(arg)) @@ -1389,7 +2205,7 @@ a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg) return retobj; } -PyObject * +static PyObject * a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self) { /* This function will create a Python generator/iterator */ @@ -1401,7 +2217,7 @@ a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self) return (PyObject *) self; } -PyObject * +static PyObject * a3dp_ENTITYLIST_iter(PyObject *self) { /* Must have the same signature as PyObject_GetIter() */ @@ -1413,7 +2229,7 @@ a3dp_ENTITYLIST_iter(PyObject *self) return self; } -PyObject * +static PyObject * a3dp_ENTITYLIST_iter_next(PyObject *self) { /* Must have the same signature as PyIter_Next() */ @@ -1425,20 +2241,98 @@ a3dp_ENTITYLIST_iter_next(PyObject *self) return a3dp_ENTITYLIST__next(_ent_list); } +static PyMethodDef + a3dp_methods_ENTITY_LIST[] = + { + { "add", (PyCFunction) a3dp_ENTITYLIST__add, METH_O, "Adds an entity or entities to the list" }, + { "remove", (PyCFunction) a3dp_ENTITYLIST__remove, METH_O, "Removes an entity or entities from the list" }, + { "count", (PyCFunction) a3dp_ENTITYLIST__count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, + { "iteration_count", (PyCFunction) a3dp_ENTITYLIST__iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, + { "init", (PyCFunction) a3dp_ENTITYLIST__init, METH_NOARGS, "Adds an entity or entities to the list" }, + { "clear", (PyCFunction) a3dp_ENTITYLIST__clear, METH_NOARGS, "Clear all entries from the list and reset indexes and counters for reuse" }, + { "lookup", (PyCFunction) a3dp_ENTITYLIST__lookup, METH_O, "Adds an entity or entities to the list" }, + { "reverse", (PyCFunction) a3dp_ENTITYLIST__reverse, METH_NOARGS, "Adds an entity or entities to the list" }, + { "byte_count", (PyCFunction) a3dp_ENTITYLIST__byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, + { "first", (PyCFunction) a3dp_ENTITYLIST__first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, + { "next", (PyCFunction) a3dp_ENTITYLIST__next, METH_NOARGS, "Returns the next undeleted (live) entry" }, + { "next_from", (PyCFunction) a3dp_ENTITYLIST__next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, + { "array", (PyCFunction) a3dp_ENTITYLIST__array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, + { NULL } /* Sentinel */ + }; + +PyTypeObject + a3dp_type_ENTITY_LIST = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.ENTITY_LIST", /* tp_name */ + sizeof(a3dp_ENTITY_LIST), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) a3dp_ENTITYLIST_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "ACIS ENTITY_LIST class", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc) a3dp_ENTITYLIST_iter, /* tp_iter */ + (iternextfunc) a3dp_ENTITYLIST_iter_next, /* tp_iternext */ + a3dp_methods_ENTITY_LIST, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) a3dp_ENTITYLIST_init, /* tp_init */ + 0, /* tp_alloc */ + a3dp_ENTITYLIST_new, /* tp_new */ + }; PyObject * _PyNew_ENTITY_LIST() { - return PyObject_CallObject((PyObject *) &a3dp_type_ENTITYLIST, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_ENTITY_LIST, NULL); } bool _PyCheck_ENTITY_LIST(PyObject *ob) { - if (Py_TYPE(ob) == &a3dp_type_ENTITYLIST) - return true; - else - return false; + return PyObject_TypeCheck(ob, &a3dp_type_ENTITY_LIST); +} + + +/** + * Additional Functions + */ + +void +__make_null(PyObject *ob) +{ + if (_PyCheck_ENTITY(ob)) + { + ((a3dp_ENTITY *) ob)->_acis_obj = NULL; + } +} + +void +__set_entity(PyObject *ob, ENTITY *ent) +{ + ((a3dp_ENTITY *)ob)->_acis_obj = ent; } PyObject * @@ -1452,17 +2346,17 @@ __convert_entity(ENTITY *ent) if (strcmp("body", _type_name) == 0) { _retobj = _PyNew_BODY(); - _a3dp_set_entity(_retobj, ent); + __set_entity(_retobj, ent); } else if (strcmp("face", _type_name) == 0) { _retobj = _PyNew_FACE(); - _a3dp_set_entity(_retobj, ent); + __set_entity(_retobj, ent); } else if (strcmp("surface", _type_name) == 0) { _retobj = _PyNew_SURFACE(); - _a3dp_set_entity(_retobj, ent); + __set_entity(_retobj, ent); } return _retobj; diff --git a/src/acis_entity.h b/src/acis_entity.h index 7743a66..30c7a73 100644 --- a/src/acis_entity.h +++ b/src/acis_entity.h @@ -19,12 +19,6 @@ #include "acis_operators.h" -#ifdef __cplusplus -extern "C" { -#endif - -// Types and their functions - // Define ENTITY as a base class typedef struct { @@ -34,1085 +28,108 @@ typedef struct PyObject *attrib_object_id; } a3dp_ENTITY; -int a3dp_ENTITY_traverse(a3dp_ENTITY *self, visitproc visit, void *arg); -int a3dp_ENTITY_clear(a3dp_ENTITY *self); -void a3dp_ENTITY_dealloc(a3dp_ENTITY *self); -PyObject *a3dp_ENTITY_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_ENTITY_init(a3dp_ENTITY *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_ENTITY_repr(a3dp_ENTITY *self); -PyObject *a3dp_ENTITY_str(a3dp_ENTITY *self); -PyObject *a3dp_ENTITY_get_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); -int a3dp_ENTITY_set_attrib_name(a3dp_ENTITY *self, PyObject *value, void *closure); -PyObject *a3dp_ENTITY_get_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); -int a3dp_ENTITY_set_attrib_obj_id(a3dp_ENTITY *self, PyObject *value, void *closure); -PyObject *a3dp_ENTITY_type_name(PyObject *self); - -static PyGetSetDef - a3dp_getseters_ENTITY[] = - { - { (char *) "name", (getter) a3dp_ENTITY_get_attrib_name, (setter) a3dp_ENTITY_set_attrib_name, (char *) "object name", NULL }, - { (char *) "id", (getter) a3dp_ENTITY_get_attrib_obj_id, (setter) a3dp_ENTITY_set_attrib_obj_id, (char *) "object id", NULL }, - { NULL } /* Sentinel */ - }; - -static PyMethodDef - a3dp_methods_ENTITY[] = - { - { "type_name", (PyCFunction) a3dp_ENTITY_type_name, METH_NOARGS, "Returns a name for this ENTITY's type" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_ENTITY = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.ENTITY", /* tp_name */ - sizeof(a3dp_ENTITY), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_ENTITY_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_ENTITY_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_ENTITY_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_GC, /* tp_flags */ - "ACIS ENTITY class", /* tp_doc */ - (traverseproc) a3dp_ENTITY_traverse, /* tp_traverse */ - (inquiry) a3dp_ENTITY_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_ENTITY, /* tp_methods */ - 0, /* tp_members */ - a3dp_getseters_ENTITY, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_ENTITY_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_ENTITY_new, /* tp_new */ - }; - -PyObject *_PyNew_ENTITY(); - -bool _PyCheck_ENTITY(PyObject *ob); - // Define BODY typedef struct { a3dp_ENTITY base_obj; } a3dp_BODY; -int a3dp_BODY_init(a3dp_BODY *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_BODY_repr(a3dp_BODY *self); -PyObject *a3dp_BODY_str(a3dp_BODY *self); - -static PyTypeObject - a3dp_type_BODY = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.BODY", /* tp_name */ - sizeof(a3dp_BODY), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_BODY_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_BODY_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS BODY class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_BODY_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - -PyObject *_PyNew_BODY(); - -bool _PyCheck_BODY(PyObject *ob); - // Define FACE typedef struct { a3dp_ENTITY base_obj; } a3dp_FACE; -int a3dp_FACE_init(a3dp_FACE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_FACE_repr(a3dp_FACE *self); -PyObject *a3dp_FACE_str(a3dp_FACE *self); -PyObject *a3dp_FACE__sense(a3dp_FACE *self); -PyObject *a3dp_FACE__geometry(a3dp_FACE *self); - -static PyMethodDef - a3dp_methods_FACE[] = - { - { "sense", (PyCFunction) a3dp_FACE__sense, METH_NOARGS, "Returns the sense of this FACE relative to its SURFACE" }, - { "geometry", (PyCFunction) a3dp_FACE__geometry, METH_NOARGS, "Returns a pointer to the underlying SURFACE defining this FACE" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_FACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.FACE", /* tp_name */ - sizeof(a3dp_FACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_FACE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_FACE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS FACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_FACE, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_FACE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_FACE(); - -bool _PyCheck_FACE(PyObject *ob); - // Define EDGE typedef struct { a3dp_ENTITY base_obj; } a3dp_EDGE; -int a3dp_EDGE_init(a3dp_EDGE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_EDGE_repr(a3dp_EDGE *self); -PyObject *a3dp_EDGE_str(a3dp_EDGE *self); - -static PyTypeObject - a3dp_type_EDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.EDGE", /* tp_name */ - sizeof(a3dp_EDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_EDGE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_EDGE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS EDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_EDGE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_EDGE(); - -bool _PyCheck_EDGE(PyObject *ob); - // Define WIRE typedef struct { a3dp_ENTITY base_obj; } a3dp_WIRE; -int a3dp_WIRE_init(a3dp_WIRE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_WIRE_repr(a3dp_WIRE *self); -PyObject *a3dp_WIRE_str(a3dp_WIRE *self); - -static PyTypeObject - a3dp_type_WIRE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.WIRE", /* tp_name */ - sizeof(a3dp_WIRE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_WIRE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_WIRE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS WIRE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_WIRE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_WIRE(); - -bool _PyCheck_WIRE(PyObject *ob); - // Define LUMP typedef struct { a3dp_ENTITY base_obj; } a3dp_LUMP; -int a3dp_LUMP_init(a3dp_LUMP *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_LUMP_repr(a3dp_LUMP *self); -PyObject *a3dp_LUMP_str(a3dp_LUMP *self); - -static PyTypeObject - a3dp_type_LUMP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LUMP", /* tp_name */ - sizeof(a3dp_LUMP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_LUMP_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_LUMP_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LUMP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_LUMP_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - -PyObject *_PyNew_LUMP(); - -bool _PyCheck_LUMP(PyObject *ob); - // Define SHELL typedef struct { a3dp_ENTITY base_obj; } a3dp_SHELL; -int a3dp_SHELL_init(a3dp_SHELL *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SHELL_repr(a3dp_SHELL *self); -PyObject *a3dp_SHELL_str(a3dp_SHELL *self); - -static PyTypeObject - a3dp_type_SHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SHELL", /* tp_name */ - sizeof(a3dp_SHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SHELL_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SHELL_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SHELL_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_SHELL(); - -bool _PyCheck_SHELL(PyObject *ob); - // Define SUBSHELL typedef struct { a3dp_ENTITY base_obj; } a3dp_SUBSHELL; -int a3dp_SUBSHELL_init(a3dp_SUBSHELL *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SUBSHELL_repr(a3dp_SUBSHELL *self); -PyObject *a3dp_SUBSHELL_str(a3dp_SUBSHELL *self); - -static PyTypeObject - a3dp_type_SUBSHELL = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SUBSHELL", /* tp_name */ - sizeof(a3dp_SUBSHELL), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SUBSHELL_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SUBSHELL_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SUBSHELL class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SUBSHELL_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_SUBSHELL(); - -bool _PyCheck_SUBSHELL(PyObject *ob); - // Define COEDGE typedef struct { a3dp_ENTITY base_obj; } a3dp_COEDGE; -int a3dp_COEDGE_init(a3dp_COEDGE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_COEDGE_repr(a3dp_COEDGE *self); -PyObject *a3dp_COEDGE_str(a3dp_COEDGE *self); - -static PyTypeObject - a3dp_type_COEDGE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.COEDGE", /* tp_name */ - sizeof(a3dp_COEDGE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_COEDGE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_COEDGE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS COEDGE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_COEDGE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_COEDGE(); - -bool _PyCheck_COEDGE(PyObject *ob); - // Define LOOP typedef struct { a3dp_ENTITY base_obj; } a3dp_LOOP; -int a3dp_LOOP_init(a3dp_LOOP *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_LOOP_repr(a3dp_LOOP *self); -PyObject *a3dp_LOOP_str(a3dp_LOOP *self); - -static PyTypeObject - a3dp_type_LOOP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.LOOP", /* tp_name */ - sizeof(a3dp_LOOP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_LOOP_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_LOOP_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS LOOP class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_LOOP_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_LOOP(); - -bool _PyCheck_LOOP(PyObject *ob); - // Define VERTEX typedef struct { a3dp_ENTITY base_obj; } a3dp_VERTEX; -int a3dp_VERTEX_init(a3dp_VERTEX *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_VERTEX_repr(a3dp_VERTEX *self); -PyObject *a3dp_VERTEX_str(a3dp_VERTEX *self); - -static PyTypeObject - a3dp_type_VERTEX = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.VERTEX", /* tp_name */ - sizeof(a3dp_VERTEX), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_VERTEX_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_VERTEX_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS VERTEX class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_VERTEX_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_VERTEX(); - -bool _PyCheck_VERTEX(PyObject *ob); - // Define SURFACE typedef struct { a3dp_ENTITY base_obj; } a3dp_SURFACE; -int a3dp_SURFACE_init(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SURFACE_repr(a3dp_SURFACE *self); -PyObject *a3dp_SURFACE_str(a3dp_SURFACE *self); -PyObject *a3dp_SURFACE__equation(a3dp_SURFACE *self); -PyObject *a3dp_SURFACE__trans_surface(a3dp_SURFACE *self, PyObject *args, PyObject *kwargs); - -static PyMethodDef - a3dp_methods_SURFACE[] = - { - { "equation", (PyCFunction) a3dp_SURFACE__equation, METH_NOARGS, "Returns the equation of this SURFACE" }, - { "trans_surface", (PyCFunction) a3dp_SURFACE__trans_surface, METH_VARARGS | METH_KEYWORDS, "Returns the transformed surface" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_SURFACE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SURFACE", /* tp_name */ - sizeof(a3dp_SURFACE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SURFACE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SURFACE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SURFACE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_SURFACE, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SURFACE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_SURFACE(); - -bool _PyCheck_SURFACE(PyObject *ob); - // Define CONE typedef struct { a3dp_ENTITY base_obj; } a3dp_CONE; -int a3dp_CONE_init(a3dp_CONE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_CONE_repr(a3dp_CONE *self); -PyObject *a3dp_CONE_str(a3dp_CONE *self); - -static PyTypeObject - a3dp_type_CONE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.CONE", /* tp_name */ - sizeof(a3dp_CONE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_CONE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_CONE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS CONE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_CONE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_CONE(); - -bool _PyCheck_CONE(PyObject *ob); - // Define PLANE typedef struct { a3dp_ENTITY base_obj; } a3dp_PLANE; -int a3dp_PLANE_init(a3dp_PLANE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_PLANE_repr(a3dp_PLANE *self); -PyObject *a3dp_PLANE_str(a3dp_PLANE *self); - -static PyTypeObject - a3dp_type_PLANE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.PLANE", /* tp_name */ - sizeof(a3dp_PLANE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_PLANE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_PLANE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS PLANE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_PLANE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_PLANE(); - -bool _PyCheck_PLANE(PyObject *ob); - // Define SPHERE typedef struct { a3dp_ENTITY base_obj; } a3dp_SPHERE; -int a3dp_SPHERE_init(a3dp_SPHERE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPHERE_repr(a3dp_SPHERE *self); -PyObject *a3dp_SPHERE_str(a3dp_SPHERE *self); - -static PyTypeObject - a3dp_type_SPHERE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPHERE", /* tp_name */ - sizeof(a3dp_SPHERE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPHERE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPHERE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPHERE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPHERE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_SPHERE(); - -bool _PyCheck_SPHERE(PyObject *ob); - // Define SPLINE typedef struct { a3dp_ENTITY base_obj; } a3dp_SPLINE; -int a3dp_SPLINE_init(a3dp_SPLINE *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_SPLINE_repr(a3dp_SPLINE *self); -PyObject *a3dp_SPLINE_str(a3dp_SPLINE *self); - -static PyTypeObject - a3dp_type_SPLINE = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.SPLINE", /* tp_name */ - sizeof(a3dp_SPLINE), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_SPLINE_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_SPLINE_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS SPLINE class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_SPLINE_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - -PyObject *_PyNew_SPLINE(); - -bool _PyCheck_SPLINE(PyObject *ob); - // Define TORUS typedef struct { a3dp_ENTITY base_obj; } a3dp_TORUS; -int a3dp_TORUS_init(a3dp_TORUS *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_TORUS_repr(a3dp_TORUS *self); -PyObject *a3dp_TORUS_str(a3dp_TORUS *self); - -static PyTypeObject - a3dp_type_TORUS = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.TORUS", /* tp_name */ - sizeof(a3dp_TORUS), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - (reprfunc) a3dp_TORUS_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) a3dp_TORUS_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS TORUS class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_TORUS_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - -PyObject *_PyNew_TORUS(); - -bool _PyCheck_TORUS(PyObject *ob); - // Define surface typedef struct { surface* _acis_obj; } a3dp_surface; -void a3dp_surface_dealloc(a3dp_surface *self); -PyObject *a3dp_surface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_surface_init(a3dp_surface *self, PyObject *args, PyObject *kwargs); -PyObject *a3dp_surface__eval_normal(a3dp_surface *self, PyObject *arg); -PyObject *a3dp_surface__eval_position(a3dp_surface *self, PyObject *arg); - -static PyMethodDef - a3dp_methods_surface[] = - { - { "eval_normal", (PyCFunction) a3dp_surface__eval_normal, METH_O, "Finds the normal to a parametric surface at the point with the given parameter position" }, - { "eval_position", (PyCFunction) a3dp_surface__eval_position, METH_O, "Finds the point on a parametric surface with the given parameter position" }, - { NULL } /* Sentinel */ - }; - -static PyTypeObject - a3dp_type_surface = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.surface", /* tp_name */ - sizeof(a3dp_surface), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_surface_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS surface class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - a3dp_methods_surface, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_surface_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_surface_new, /* tp_new */ - }; - -PyObject *_PyNew_surface(); - -bool _PyCheck_surface(PyObject *ob); - // Define ENTITY_LIST typedef struct { @@ -1120,93 +137,86 @@ typedef struct ENTITY_LIST *_acis_obj; } a3dp_ENTITY_LIST; -void a3dp_ENTITYLIST_dealloc(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST_new(PyTypeObject *type, PyObject *args, PyObject *kwargs); -int a3dp_ENTITYLIST_init(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__init(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__clear(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__add(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__remove(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__count(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__iteration_count(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__reverse(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__lookup(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__byte_count(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__first(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__next(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST__next_from(a3dp_ENTITY_LIST *self, PyObject *arg); -PyObject *a3dp_ENTITYLIST__array(a3dp_ENTITY_LIST *self); -PyObject *a3dp_ENTITYLIST_iter(PyObject *self); -PyObject *a3dp_ENTITYLIST_iter_next(PyObject *self); +extern PyTypeObject a3dp_type_ENTITY; +extern PyTypeObject a3dp_type_BODY; +extern PyTypeObject a3dp_type_FACE; +extern PyTypeObject a3dp_type_EDGE; +extern PyTypeObject a3dp_type_WIRE; +extern PyTypeObject a3dp_type_LUMP; +extern PyTypeObject a3dp_type_SHELL; +extern PyTypeObject a3dp_type_SUBSHELL; +extern PyTypeObject a3dp_type_COEDGE; +extern PyTypeObject a3dp_type_LOOP; +extern PyTypeObject a3dp_type_VERTEX; +extern PyTypeObject a3dp_type_SURFACE; +extern PyTypeObject a3dp_type_CONE; +extern PyTypeObject a3dp_type_PLANE; +extern PyTypeObject a3dp_type_SPHERE; +extern PyTypeObject a3dp_type_SPLINE; +extern PyTypeObject a3dp_type_TORUS; +extern PyTypeObject a3dp_type_surface; +extern PyTypeObject a3dp_type_ENTITY_LIST; + +#ifdef __cplusplus +extern "C" { +#endif -static PyMethodDef - a3dp_methods_ENTITY_LIST[] = - { - { "add", (PyCFunction) a3dp_ENTITYLIST__add, METH_O, "Adds an entity or entities to the list" }, - { "remove", (PyCFunction) a3dp_ENTITYLIST__remove, METH_O, "Removes an entity or entities from the list" }, - { "count", (PyCFunction) a3dp_ENTITYLIST__count, METH_NOARGS, "Returns the number of entries in the list including the deleted ones (tombstones)" }, - { "iteration_count", (PyCFunction) a3dp_ENTITYLIST__iteration_count, METH_NOARGS, "Returns the number of live entities in the list not including deleted entries" }, - { "init", (PyCFunction) a3dp_ENTITYLIST__init, METH_NOARGS, "Adds an entity or entities to the list" }, - { "clear", (PyCFunction) a3dp_ENTITYLIST__clear, METH_NOARGS, "Clear all entries from the list and reset indexes and counters for reuse" }, - { "lookup", (PyCFunction) a3dp_ENTITYLIST__lookup, METH_O, "Adds an entity or entities to the list" }, - { "reverse", (PyCFunction) a3dp_ENTITYLIST__reverse, METH_NOARGS, "Adds an entity or entities to the list" }, - { "byte_count", (PyCFunction) a3dp_ENTITYLIST__byte_count, METH_NOARGS, "Returns the size in bytes of this class" }, - { "first", (PyCFunction) a3dp_ENTITYLIST__first, METH_NOARGS, "Initializes the iterator, which is used by the next method, to the beginning of the list" }, - { "next", (PyCFunction) a3dp_ENTITYLIST__next, METH_NOARGS, "Returns the next undeleted (live) entry" }, - { "next_from", (PyCFunction) a3dp_ENTITYLIST__next_from, METH_O, "Returns the next non deleted entry after the index given without affecting the member variables used by init and next" }, - { "array", (PyCFunction) a3dp_ENTITYLIST__array, METH_NOARGS, "Gets an array of the entities in the list (creates a Python generator)" }, - { NULL } /* Sentinel */ - }; +PyObject *_PyNew_ENTITY(); +bool _PyCheck_ENTITY(PyObject *ob); -static PyTypeObject - a3dp_type_ENTITYLIST = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.ENTITY_LIST", /* tp_name */ - sizeof(a3dp_ENTITY_LIST), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) a3dp_ENTITYLIST_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "ACIS ENTITY_LIST class", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) a3dp_ENTITYLIST_iter, /* tp_iter */ - (iternextfunc) a3dp_ENTITYLIST_iter_next, /* tp_iternext */ - a3dp_methods_ENTITY_LIST, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) a3dp_ENTITYLIST_init, /* tp_init */ - 0, /* tp_alloc */ - a3dp_ENTITYLIST_new, /* tp_new */ - }; +PyObject *_PyNew_BODY(); +bool _PyCheck_BODY(PyObject *ob); -PyObject *_PyNew_ENTITY_LIST(); +PyObject *_PyNew_FACE(); +bool _PyCheck_FACE(PyObject *ob); -bool _PyCheck_ENTITY_LIST(PyObject *ob); +PyObject *_PyNew_EDGE(); +bool _PyCheck_EDGE(PyObject *ob); -PyObject *__convert_entity(ENTITY *ent); +PyObject *_PyNew_WIRE(); +bool _PyCheck_WIRE(PyObject *ob); + +PyObject *_PyNew_LUMP(); +bool _PyCheck_LUMP(PyObject *ob); + +PyObject *_PyNew_SHELL(); +bool _PyCheck_SHELL(PyObject *ob); +PyObject *_PyNew_SUBSHELL(); +bool _PyCheck_SUBSHELL(PyObject *ob); + +PyObject *_PyNew_COEDGE(); +bool _PyCheck_COEDGE(PyObject *ob); + +PyObject *_PyNew_LOOP(); +bool _PyCheck_LOOP(PyObject *ob); + +PyObject *_PyNew_VERTEX(); +bool _PyCheck_VERTEX(PyObject *ob); + +PyObject *_PyNew_SURFACE(); +bool _PyCheck_SURFACE(PyObject *ob); + +PyObject *_PyNew_CONE(); +bool _PyCheck_CONE(PyObject *ob); + +PyObject *_PyNew_PLANE(); +bool _PyCheck_PLANE(PyObject *ob); + +PyObject *_PyNew_SPHERE(); +bool _PyCheck_SPHERE(PyObject *ob); + +PyObject *_PyNew_SPLINE(); +bool _PyCheck_SPLINE(PyObject *ob); + +PyObject *_PyNew_TORUS(); +bool _PyCheck_TORUS(PyObject *ob); + +PyObject *_PyNew_surface(); +bool _PyCheck_surface(PyObject *ob); + +PyObject *_PyNew_ENTITY_LIST(); +bool _PyCheck_ENTITY_LIST(PyObject *ob); // Additional functions @@ -1214,9 +224,11 @@ PyObject *__convert_entity(ENTITY *ent); * Sets the internal ocis_obj variable to NULL * @param ob Topology object, such as ENTITY, BODY, FACE, etc. */ -void _a3dp_make_null(PyObject *ob); +void __make_null(PyObject *ob); -void _a3dp_set_entity(PyObject *ob, ENTITY *ent); +void __set_entity(PyObject *ob, ENTITY *ent); + +PyObject *__convert_entity(ENTITY *ent); #ifdef __cplusplus } diff --git a/src/acis_enums.cpp b/src/acis_enums.cpp index bdb4100..9f42192 100644 --- a/src/acis_enums.cpp +++ b/src/acis_enums.cpp @@ -1,22 +1,81 @@ #include "acis_enums.h" +/** + * NDBOOL_KEEP enum + */ +PyTypeObject + a3dp_type_NDBOOL_KEEP = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.NDBOOL_KEEP", /* tp_name */ + sizeof(a3dp_NDBOOL_KEEP), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ + }; PyObject *_PyNew_NDBOOL_KEEP() { - return PyObject_CallObject((PyObject *) &a3dp_type_NDBOOLKEEP, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_NDBOOL_KEEP, NULL); } bool _PyCheck_NDBOOL_KEEP(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_NDBOOLKEEP; + return Py_TYPE(ob) == &a3dp_type_NDBOOL_KEEP; } + +/** + * sweep_bool_type enum + */ + +PyTypeObject + a3dp_type_sweep_bool_type = + { + PyVarObject_HEAD_INIT(NULL, 0) + "ACIS.sweep_bool_type", /* tp_name */ + sizeof(a3dp_sweep_bool_type), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "Sweep to body boolean operation type", /* tp_doc */ + }; + PyObject *_PyNew_sweep_bool_type() { - return PyObject_CallObject((PyObject *) &a3dp_type_sweepbooltype, NULL); + return PyObject_CallObject((PyObject *) &a3dp_type_sweep_bool_type, NULL); } bool _PyCheck_sweep_bool_type(PyObject *ob) { - return Py_TYPE(ob) == &a3dp_type_sweepbooltype; + return Py_TYPE(ob) == &a3dp_type_sweep_bool_type; } diff --git a/src/acis_enums.h b/src/acis_enums.h index 695ac49..6d2ddd0 100644 --- a/src/acis_enums.h +++ b/src/acis_enums.h @@ -15,82 +15,26 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif // Define NDBOOL_KEEP enum typedef struct { PyObject_HEAD } a3dp_NDBOOL_KEEP; -/** - * NDBOOL_KEEP enum - */ - -static PyTypeObject - a3dp_type_NDBOOLKEEP = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.NDBOOL_KEEP", /* tp_name */ - sizeof(a3dp_NDBOOL_KEEP), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "For a non-destructive Boolean operation, this optional flag may be used to specify the preservation of either or both input bodies", /* tp_doc */ - }; - -PyObject *_PyNew_NDBOOL_KEEP(); -bool _PyCheck_NDBOOL_KEEP(PyObject *ob); - // Define sweep_bool_type enum typedef struct { PyObject_HEAD } a3dp_sweep_bool_type; -/** - * sweep_bool_type enum - */ +extern PyTypeObject a3dp_type_NDBOOL_KEEP; +extern PyTypeObject a3dp_type_sweep_bool_type; -static PyTypeObject - a3dp_type_sweepbooltype = - { - PyVarObject_HEAD_INIT(NULL, 0) - "ACIS.sweep_bool_type", /* tp_name */ - sizeof(a3dp_sweep_bool_type), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Sweep to body boolean operation type", /* tp_doc */ - }; +#ifdef __cplusplus +extern "C" { +#endif + +PyObject *_PyNew_NDBOOL_KEEP(); +bool _PyCheck_NDBOOL_KEEP(PyObject *ob); PyObject *_PyNew_sweep_bool_type(); bool _PyCheck_sweep_bool_type(PyObject *ob); diff --git a/src/acis_modeler.cpp b/src/acis_modeler.cpp index 3d3d0f0..8fa0fe5 100644 --- a/src/acis_modeler.cpp +++ b/src/acis_modeler.cpp @@ -107,22 +107,22 @@ PyInit_Modeler(void) PyModule_AddObject(m, "SPAvector", (PyObject *) &a3dp_type_SPAvector); // SPAunit_vector - if (PyType_Ready(&a3dp_type_SPAunitvector) < 0) + if (PyType_Ready(&a3dp_type_SPAunit_vector) < 0) return NULL; - Py_INCREF(&a3dp_type_SPAunitvector); - PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &a3dp_type_SPAunitvector); + Py_INCREF(&a3dp_type_SPAunit_vector); + PyModule_AddObject(m, "SPAunit_vector", (PyObject *) &a3dp_type_SPAunit_vector); // SPApar_pos - if (PyType_Ready(&a3dp_type_SPAparpos) < 0) + if (PyType_Ready(&a3dp_type_SPApar_pos) < 0) return NULL; - Py_INCREF(&a3dp_type_SPAparpos); - PyModule_AddObject(m, "SPApar_pos", (PyObject *) &a3dp_type_SPAparpos); + Py_INCREF(&a3dp_type_SPApar_pos); + PyModule_AddObject(m, "SPApar_pos", (PyObject *) &a3dp_type_SPApar_pos); // SPApar_vec - if (PyType_Ready(&a3dp_type_SPAparvec) < 0) + if (PyType_Ready(&a3dp_type_SPApar_vec) < 0) return NULL; - Py_INCREF(&a3dp_type_SPAparvec); - PyModule_AddObject(m, "SPApar_vec", (PyObject *) &a3dp_type_SPAparvec); + Py_INCREF(&a3dp_type_SPApar_vec); + PyModule_AddObject(m, "SPApar_vec", (PyObject *) &a3dp_type_SPApar_vec); if (PyType_Ready(&a3dp_type_FileInfo) < 0) return NULL; @@ -142,11 +142,11 @@ PyInit_Modeler(void) } // NDBOOL_KEEP - a3dp_type_NDBOOLKEEP.tp_dict = _ndbk_dict; - if (PyType_Ready(&a3dp_type_NDBOOLKEEP) < 0) + a3dp_type_NDBOOL_KEEP.tp_dict = _ndbk_dict; + if (PyType_Ready(&a3dp_type_NDBOOL_KEEP) < 0) return NULL; - Py_INCREF(&a3dp_type_NDBOOLKEEP); - PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &a3dp_type_NDBOOLKEEP); + Py_INCREF(&a3dp_type_NDBOOL_KEEP); + PyModule_AddObject(m, "NDBOOL_KEEP", (PyObject *) &a3dp_type_NDBOOL_KEEP); // Create a dictionary object for sweep_bool_type enum PyObject *_sbt_dict; @@ -161,11 +161,11 @@ PyInit_Modeler(void) } // sweep_bool_type - a3dp_type_sweepbooltype.tp_dict = _sbt_dict; - if (PyType_Ready(&a3dp_type_sweepbooltype) < 0) + a3dp_type_sweep_bool_type.tp_dict = _sbt_dict; + if (PyType_Ready(&a3dp_type_sweep_bool_type) < 0) return NULL; - Py_INCREF(&a3dp_type_sweepbooltype); - PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &a3dp_type_sweepbooltype); + Py_INCREF(&a3dp_type_sweep_bool_type); + PyModule_AddObject(m, "sweep_bool_type", (PyObject *) &a3dp_type_sweep_bool_type); // sweep_options if (PyType_Ready(&a3dp_type_sweep_options) < 0) @@ -304,10 +304,10 @@ PyInit_Modeler(void) PyModule_AddObject(m, "surface", (PyObject *) &a3dp_type_surface); // Initialize ACIS ENTITY_LIST class as a Python type - if (PyType_Ready(&a3dp_type_ENTITYLIST) < 0) + if (PyType_Ready(&a3dp_type_ENTITY_LIST) < 0) return NULL; - Py_INCREF(&a3dp_type_ENTITYLIST); - PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &a3dp_type_ENTITYLIST); + Py_INCREF(&a3dp_type_ENTITY_LIST); + PyModule_AddObject(m, "ENTITY_LIST", (PyObject *) &a3dp_type_ENTITY_LIST); return m; } diff --git a/src/acis_spa.cpp b/src/acis_spa.cpp deleted file mode 100644 index 5e867d3..0000000 --- a/src/acis_spa.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "acis_spa.h" - - -PyObject * -a3dp_spa_unlock_products(PyObject *self, PyObject *arg) -{ - // Check if the input is a string - if (!PyUnicode_Check(arg)) - { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } - - // Convert PyObject to C-style string - const char *unlock_str = PyUnicode_AsUTF8(arg); - - // Call ACIS Licensing API - spa_unlock_result out = spa_unlock_products(unlock_str); - - // If license is good, then return True. Otherwise, return the licensing error message - if (SPA_UNLOCK_PASS == out.get_state()) - Py_RETURN_TRUE; - else - return PyUnicode_FromString(out.get_message_text()); -} diff --git a/src/acis_spa.h b/src/acis_spa.h deleted file mode 100644 index 9764acd..0000000 --- a/src/acis_spa.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - * Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler - * - * ACIS and SAT are registered trademarks of Spatial Corporation. - * - * The Python module is developed by Onur R. Bingol and released under MIT license. - * Please see the LICENSE file for details. - * - */ - -#ifndef A3D_SPA_H -#define A3D_SPA_H - -#include - -#include "acis_includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -PyObject *a3dp_spa_unlock_products(PyObject *self, PyObject *arg); - -#ifdef __cplusplus -} -#endif - -#endif // !A3D_SPA_H From b142d821e7221ff4a32417665bf366a55884edca Mon Sep 17 00:00:00 2001 From: "Onur R. Bingol" Date: Sun, 10 Dec 2017 03:14:39 -0600 Subject: [PATCH 9/9] Update function reference and contribution docs --- CONTRIBUTING.md | 9 ++-- FUNCTION_REFERENCE.md | 121 +++++++++++++----------------------------- 2 files changed, 40 insertions(+), 90 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd23451..8db3c7e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,12 +27,9 @@ I would like to introduce some rules on contributing to this module. #### Naming conventions in the Python module -* Python objects are defined as `ACIS_{ModuleName}_{ACISName}` and located in the header files -* Type functions are defined as `ACIS_{ModuleName}_{function_name}_{ACISName}`, e.g. _a3dp_init_SPAposition_ -* Methods for types are defined as `ACIS_{ModuleName}_method_{ACISName}_{MethodName}`, e.g. _a3dp_method_ENTITY_LIST_add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side -* Module variables are defined as `ACIS_{ModuleName}_{function_name}`, e.g. _ACIS_Topology_module_ -* Module init functions are defined as `PyInit_{ModuleName}` -* ACIS API calls are defined as `ACIS_{API Call}`, e.g. _ACIS_api_start_modeller_ which corresponds to _api_start_modeller()_ on the C++ side +* Type functions: `a3dp_{ACISName}_{function_name}`, e.g. _a3dp_SPAposition_init_ which corresponds to Python's _tp_init_ function. +* Methods for types: `a3dp_{ACISName}__{MethodName}`, e.g. _a3dp_ENTITY_LIST__add_ which corresponds to _ENTITY_LIST::add()_ on the C++ side +* ACIS API calls: `a3dp_{API-Call}`, e.g. _a3dp_api_start_modeller_ which corresponds to _api_start_modeller()_ on the C++ side ### Contribution in general diff --git a/FUNCTION_REFERENCE.md b/FUNCTION_REFERENCE.md index 07841b3..86ce8d0 100644 --- a/FUNCTION_REFERENCE.md +++ b/FUNCTION_REFERENCE.md @@ -2,10 +2,9 @@ **Note:** Some class methods might be missing. Please see [CONTRIBUTING](CONTRIBUTING.md) file for details. -## Modeler - -### Functions +## API Calls +* spa_unlock_products * api_start_modeller (api_start_modeler) * api_stop_modeller (api_stop_modeler) * is_modeler_started @@ -22,42 +21,6 @@ * api_apply_transf * api_remove_transf * api_sheet_from_ff - -## Entity - -### Classes - -* ENTITY -* BODY -* LUMP -* SHELL -* SUBSHELL -* FACE -* EDGE -* COEDGE -* VERTEX -* WIRE -* SURFACE -* CONE -* PLANE -* SPHERE -* SPLINE -* TORUS - -## Geometric Atoms - -### Classes - -* SPAposition -* SPAtransf -* SPAmatrix -* SPAvector -* SPAunit_vector -* SPApar_pos -* SPApar_vec - -### Functions - * coordinate_transf * make_transf * reflect_transf @@ -78,63 +41,53 @@ * get_resnor * distance_to_point * distance_to_point_squared - -## Lists - -### Classes - -* ENTITY_LIST - -## Query - -### Functions - * get_owner_transf * api_get_faces * api_get_edges - -## Save & Restore - -### Classes - -* FileInfo - -### Functions - * api_save_entity_list * api_set_file_info * api_get_file_info * api_save_version - -## Sweeping - -### Classes / Enums - -* sweep_bool_type -* sweep_options -* make_sweep_path_options - -### Functions - +* api_unite +* api_intersect +* api_subtract +* api_imprint +* api_boolean_chop_body * api_make_sweep_path * api_sweep_with_options -## Licensing - -### Functions -* spa_unlock_products +## Classes -## Booleans +* ENTITY +* BODY +* LUMP +* SHELL +* SUBSHELL +* FACE +* EDGE +* COEDGE +* VERTEX +* WIRE +* SURFACE +* CONE +* PLANE +* SPHERE +* SPLINE +* TORUS +* ENTITY_LIST +* SPAposition +* SPAtransf +* SPAmatrix +* SPAvector +* SPAunit_vector +* SPApar_pos +* SPApar_vec +* FileInfo +* sweep_options +* make_sweep_path_options -### Enums +## Enums +* sweep_bool_type * NDBOOL_KEEP - -### Functions - -* api_unite -* api_intersect -* api_subtract -* api_imprint -* api_boolean_chop_body