├── .gitignore ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── ChangeLog ├── README ├── README.md ├── build-mingw ├── build.properties ├── build.sh ├── build.xml ├── doc ├── Example1.java └── runExample1.sh ├── occ-BRepMesh_FastDiscret.patch ├── occ-BRepMesh_FastDiscretFace.patch ├── occ-mingw-makefile.patch ├── occ-mingw-port.patch ├── src-java-test └── org │ └── jcae │ └── opencascade │ └── jni │ ├── BRepBuilder.java │ ├── CircleExtrudeQuilt.java │ ├── Curvature.java │ ├── Dimensions.java │ ├── Explorer.java │ ├── FixSmallEdges.java │ ├── HoleFilletChamfer.java │ ├── Jina2006.java │ ├── NativeStream.java │ ├── RemoveFace.java │ ├── STEPLabel.java │ ├── SplitFace.java │ ├── TopoJunction.java │ ├── TrimmedSphere.java │ └── Wire.java ├── src-java └── org │ └── jcae │ └── opencascade │ ├── Shape.java │ ├── Utilities.java │ └── jni │ ├── BRepOffsetAPI_Sewing.java │ ├── Geom2d_GeometryEnum.java │ └── Geom_GeometryEnum.java ├── src ├── APIHeaderSection_MakeHeader.i ├── BRep.i ├── BRepAlgoAPI.i ├── BRepBuilderAPI.i ├── BRepCheck.i ├── BRepFilletAPI.i ├── BRepLib.i ├── BRepOffsetAPI.i ├── BRepPrimAPI.i ├── BRepTools.i ├── GC.i ├── Geom.i ├── GeomAPI.i ├── GeomAbs.i ├── GeomLProp_SLProps.i ├── Makefile.am ├── OccJava.i ├── Poly.i ├── ShapeAnalysis.i ├── ShapeBuild.i ├── ShapeFix.i ├── ShapeUpgrade.i ├── Standard.i ├── TCol.i ├── TopAbs.i ├── TopTools.i ├── TopoDS.i ├── XSControl.i ├── gp.i ├── jnistream.cxx └── jnistream.hxx └── test └── input └── cube.stp /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Logs and databases # 24 | ###################### 25 | *.log 26 | *.sql 27 | *.sqlite 28 | 29 | # OS generated files # 30 | ###################### 31 | .DS_Store 32 | .DS_Store? 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | ehthumbs.db 37 | Thumbs.db 38 | 39 | # specific files/directories # 40 | ############################## 41 | 42 | /build 43 | /classes 44 | /src-java/org/jcae/opencascade/jni/* 45 | !/src-java/org/jcae/opencascade/jni/BRepOffsetAPI_Sewing.java 46 | !/src-java/org/jcae/opencascade/jni/Geom2d_GeometryEnum.java 47 | !/src-java/org/jcae/opencascade/jni/Geom_GeometryEnum.java 48 | 49 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Main programmer 2 | --------------- 3 | 4 | Jerome Robert 5 | 6 | Extensions for OntoBREP 7 | ----------------------- 8 | 9 | Alexander Perzylo 10 | Wolfgang Nicka 11 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | find_package(SWIG REQUIRED) 3 | include(${SWIG_USE_FILE}) 4 | find_package(JNI REQUIRED) 5 | 6 | #From oce/examples/find_package_components/CMakeLists.txt 7 | set(OCE_TOOLKITS TKBRep TKBool TKG2d TKG3d TKGeomBase TKIGES TKMath TKOffset TKXSBase TKernel TKSTEP TKPrim TKTopAlgo TKFillet TKMesh TKBO TKGeomAlgo TKShHealing TKSTEPBase) 8 | find_package(OCE COMPONENTS ${OCE_TOOLKITS}) 9 | if(OCE_FOUND) 10 | message(STATUS "Found OCE version ${OCE_VERSION}") 11 | if(NOT OCE_ALL_FOUND) 12 | set(OCE_FOUND false) 13 | message(WARNING "Ignoring OCE installation due to missing toolkit(s): ${OCE_MISSING_TOOLKITS}") 14 | endif(NOT OCE_ALL_FOUND) 15 | endif(OCE_FOUND) 16 | 17 | if(OCE_FOUND) 18 | # Include files reside in ${OCE_INCLUDE_DIRS}; 19 | include_directories(${OCE_INCLUDE_DIRS}) 20 | # We do not need library path, they will be automatically imported. 21 | else(OCE_FOUND) 22 | # OCE not found; either it is not found and user 23 | # has to set OCE_DIR to the directory containing 24 | # OCEConfig.cmake, or OCE is not installed and we 25 | # try to find OpenCascade files. 26 | find_path(OCC_INCLUDE_PATH "TopoDS_Shape.hxx" PATHS ENV CASROOT PATH_SUFFIXES inc include opencascade) 27 | if(NOT OCC_INCLUDE_PATH) 28 | message(FATAL_ERROR "Header file TopoDS_Shape.hxx not found. To specify paths of OpenCascade files, you may either define the CASROOT environment variable, or set both OCC_INCLUDE_PATH and OCC_LIB_PATH variables.") 29 | endif(NOT OCC_INCLUDE_PATH) 30 | 31 | if(WIN32) 32 | set(OCC_LIB_EXTRA_PATH "win32") 33 | else(WIN32) 34 | set(OCC_LIB_EXTRA_PATH "lin") 35 | endif(WIN32) 36 | find_library(OCC_LIB_PATH TKernel PATHS ENV CASROOT PATH_SUFFIXES lib64 lib 37 | ${OCC_LIB_EXTRA_PATH}/lib ${OCC_LIB_EXTRA_PATH}/vc8/lib) 38 | if(NOT OCC_LIB_PATH) 39 | message(FATAL_ERROR "OpenCascade TKernel library not found. To specify paths of OpenCascade files, you may either define the CASROOT environment variable, or set both OCC_INCLUDE_PATH and OCC_LIB_PATH variables.") 40 | endif(NOT OCC_LIB_PATH) 41 | message(STATUS "OCC search path for include files: OCC_INCLUDE_PATH=${OCC_INCLUDE_PATH}") 42 | include_directories(${OCC_INCLUDE_PATH}) 43 | message(STATUS "OCC search path for libraries: OCC_LIB_PATH=${OCC_LIB_PATH}") 44 | link_directories(${OCC_LIB_PATH}) 45 | endif(OCE_FOUND) 46 | 47 | set_source_files_properties(src/OccJava.i PROPERTIES CPLUSPLUS ON) 48 | include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} ${OCE_INCLUDE_DIR} src) 49 | set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_SOURCE_DIR}/src-java/org/jcae/opencascade/jni) 50 | set(CMAKE_SWIG_FLAGS -package org.jcae.opencascade.jni) 51 | 52 | SWIG_ADD_MODULE(OccJava java src/OccJava.i src/jnistream.cxx) 53 | SWIG_LINK_LIBRARIES(OccJava ${OCE_TOOLKITS}) 54 | 55 | if(WIN32) 56 | add_definitions(-DWNT) 57 | if(MINGW) 58 | set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--add-stdcall-alias ${CMAKE_MODULE_LINKER_FLAGS}") 59 | #We want OccJava.dll, not libOccJava.dll 60 | set_target_properties(${SWIG_MODULE_OccJava_REAL_NAME} PROPERTIES PREFIX "") 61 | endif(MINGW) 62 | endif(WIN32) 63 | 64 | install( 65 | FILES ${CMAKE_CURRENT_BINARY_DIR}/libOccJava.so 66 | DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 67 | ) 68 | 69 | #CMake won't create this directory it self. A bug ? 70 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src) 71 | 72 | 73 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2009-05-04 23:31:56 Denis Barbier 2 | 3 | * src/GeomAbs.i: Drop GeomAbs_C0, GeomAbs_C1, etc. 4 | These members have been obsoleted a long time ago and are 5 | no more used. 6 | 7 | 2009-05-04 21:22:49 Denis Barbier 8 | 9 | * src/OccJava.i: Replace %include "enumtypeunsafe.swg" by 10 | %include "enums.swg" to use Java 1.5 enums. The following 11 | classes are thus modified: ChFi3d_FilletShape, GeomAbs_Shape, 12 | IFSelect_ReturnStatus, TopAbs_ShapeEnum, TopAbs_Orientation 13 | and STEPControl_StepModelType. 14 | 15 | 2009-04-30 12:17:58 Denis Barbier 16 | 17 | * src/OccJava.i: In BRepGProp, add SurfaceProperties and 18 | VolumeProperties variants with an epsilon parameter. 19 | 20 | 2008-10-14 09:56:03 Denis Barbier 21 | 22 | * src/OccJava.i: Fix compilation with OpenCASCADE 6.3.0, BRepMesh 23 | API has changed. 24 | 25 | 2008-01-31 15:33 Jerome Robert 26 | 27 | * src/XSControl.i: Implement STEPControl_Reader.getLabel to 28 | retrieve STEP labels 29 | 30 | 2007-11-13 12:50 Jerome Robert 31 | 32 | * src-java/org/jcae/opencascade/test/FixSmallEdges.java, 33 | src/Makefile.am, src/OccJava.i, src/ShapeFix.i: Add classes to 34 | remove small edges 35 | 36 | 2007-09-28 08:33 Jerome Robert 37 | 38 | * src-java/org/jcae/opencascade/test/CircleExtrudeQuilt.java: Write 39 | the output file to the system dependent temporary directory. 40 | 41 | 2007-09-24 15:48 Jerome Robert 42 | 43 | * src-java/org/jcae/opencascade/Utilities.java, src/Makefile.am, 44 | src/OccJava.i, src/XSControl.i: Fix charset encoding problems 45 | when reading STEP or IGES files 46 | 47 | 2007-08-22 09:40 Jerome Robert 48 | 49 | * configure.ac: Link to required libTKFillet.so 50 | 51 | * src/gp.i: Add gp_Pln typemap. It allows to easily add method 52 | which use gp_Pln as input or output. gp_Pln is mapped to 53 | double[4]. 54 | 55 | 2007-07-19 09:49 Jerome Robert 56 | 57 | * README: Add list of required OCC libraries 58 | 59 | 2007-06-29 15:18 Jerome Robert 60 | 61 | * src-java/org/jcae/opencascade/test/NativeStream.java: Test 62 | reading empty stream 63 | 64 | 2007-06-26 07:25 Jerome Robert 65 | 66 | * src/OccJava.i: Fix a segfault in Bnd_Box.get 67 | 68 | 2007-06-25 08:35 Jerome Robert 69 | 70 | * src-java/org/jcae/opencascade/Utilities.java: Add 71 | Utilities.tolerance method 72 | 73 | 2007-06-21 16:39 Jerome Robert 74 | 75 | * src-java/org/jcae/opencascade/test/SplitFace.java, 76 | src/ShapeUpgrade.i: Add ShapeUpgade_ShapeDivideArea 77 | 78 | * src-java/org/jcae/opencascade/test/HoleFilletChamfer.java, 79 | src/Makefile.am, src/OccJava.i, src/ShapeUpgrade.i: Add 80 | ShapeUpgrade_RemoveInternalWires 81 | 82 | 2007-06-19 13:59 Jerome Robert 83 | 84 | * src/Poly.i, src/gp.i: Return uv nodes from Poly_Triangulation 85 | (contrib Erwann) 86 | 87 | * src/GeomLProp_SLProps.i: Adding normal array computation on 88 | GeomLProp_SLProps. This is faster than doing it on one value at a 89 | time. (contrib Erwann) 90 | 91 | * src/OccJava.i: Fix a NullPointerException when MMGT_OPT is not 92 | set 93 | 94 | 2007-06-14 12:40 Jerome Robert 95 | 96 | * src-java/org/jcae/opencascade/Utilities.java: Display tolerance 97 | in Utilities.dump 98 | 99 | 2007-05-21 14:12 Jerome Robert 100 | 101 | * src-java/org/jcae/opencascade/test/: Add many examples 102 | 103 | 2007-05-14 14:30 Jerome Robert 104 | 105 | * build.xml, src-java/org/jcae/opencascade/test, src-java/test: 106 | Rename test package to org.jcae.opencascade.test. 107 | 108 | 2007-05-11 16:10 Jerome Robert 109 | 110 | * src/BRepBuilderAPI.i: Change BRepBuilderAPI::Load to load 111 | 112 | 2007-05-10 13:24 Jerome Robert 113 | 114 | * README, src-java/test/Test7.java, src/BRepTools.i, 115 | src/Standard.i: Add istream typemap 116 | 117 | * src/OccJava.i: Throw an exception if MMGT_OPT is not set to 0 118 | 119 | * src/gp.i: Fix GeomLProp_SLProps::tangent* methods 120 | 121 | 2007-05-03 11:33 Jerome Robert 122 | 123 | * Makefile.am, build.xml, 124 | src-java/org/jcae/opencascade/jni/BRepOffsetAPI_Sewing.java, 125 | src/BRepBuilderAPI.i, src/BRepOffsetAPI_Sewing.i, 126 | src/Makefile.am, src/OccJava.i: Merge BRepOffsetAPI_Sewing with 127 | BRepBuilderAPI_Sewing and make it deprecated. Run ant from the 128 | Makefile. 129 | 130 | 2007-05-03 10:18 Jerome Robert 131 | 132 | * occjava-swig.vcproj: Fix compilation on Windows which was broken 133 | since the addition on fille and chamfer class (contrib Erwann 134 | Feat) 135 | 136 | 2007-05-03 10:16 Jerome Robert 137 | 138 | * src/BRepBuilderAPI.i, src/BRepCheck.i, src/Geom.i, src/OccJava.i, 139 | src/ShapeBuild.i: Add BRepCheck_Analyzer, ShapeBuild_ReShape, 140 | BRepBuilderAPI_Sewing, more Geom_Surface methods (contrib Erwann 141 | Feat) 142 | 143 | 2007-05-02 04:06 Jerome Robert 144 | 145 | * src/OccJava.i: add BRepGProp::SurfaceProperties and 146 | BRepGProp::VolumeProperties 147 | 148 | 2006-04-26 14:25 tag V0_14_1 149 | 150 | 2007-04-26 12:54 Jerome Robert 151 | 152 | * build.xml: Exclude tests from the release jar 153 | 154 | 2007-04-24 17:04 Jerome Robert 155 | 156 | * src/BRepPrimAPI.i: add BRepPrimAPI_MakeRevol 157 | 158 | 2007-04-23 15:11 Jerome Robert 159 | 160 | * src-java/test/Test6.java, src/BRepFilletAPI.i, src/Makefile.am, 161 | src/OccJava.i: Allow to make fillet and chamfer 162 | * src-java/org/jcae/opencascade/Utilities.java, 163 | src-java/test/Utilities.java: Move utilities from test to 164 | official package. This class should not be used outside jCAE as 165 | it's API may change. 166 | 167 | 2007-04-17 11:04:53 Denis Barbier 168 | 169 | * configure.ac: Remove -Wl,-rpath-link linker flag, it is 170 | not supported on Darwin, environment variables are set 171 | instead. Thanks to nyholku 172 | https://sf.net/forum/message.php?msg_id=4255715 173 | * acsite.m4: We only support javac for now, check it first 174 | before other Java compiler alternatives. This can be 175 | overridden by JAVAC configure command-line flag. 176 | 177 | 2007-04-12 10:35:52 Denis Barbier 178 | 179 | * acsite.m4: Fix JVM detection on Darwin, thanks to nyholku 180 | https://sf.net/forum/message.php?msg_id=4255715 181 | 182 | 2007-04-10 10:59:04 Denis Barbier 183 | 184 | * autogen.sh: Fix bashism, patch by nyholku 185 | https://sf.net/forum/message.php?msg_id=4249115 186 | * configure.ac: Replace AC_CONFIG_HEADERS by AM_CONFIG_HEADER. 187 | Patch by nyholku https://sf.net/forum/message.php?msg_id=4249115 188 | 189 | 2006-04-04 10:27:00 tag V0_14 190 | 191 | 2007-03-30 07:42:00 Jerome Robert 192 | 193 | * src-java/test/Test4.java, src/BRepBuilderAPI.i, src/BRepTools.i, 194 | src/gp.i: Add BRepTools_Quilt and gp_Circ, allow to create holed 195 | faces and circles 196 | 197 | 2007-03-07 09:12:00 Jerome Robert 198 | 199 | * src/BRepPrimAPI.i: Add BRepPrimAPI_MakePrism 200 | 201 | 2006-11-20 11:19:00 Denis Barbier 202 | 203 | * src-java/test/Test1.java: Compute vertex1 parameters on the 204 | surface 205 | 206 | 2006-11-20 10:49:00 Jerome Robert 207 | 208 | * src-java/test/Test1.java, src/BRep.i, src/BRep_Tool.i, 209 | src/Makefile.am, src/OccJava.i, src/TopoDS.i: Allow to set UV 210 | coords of a vertex on a face. Move some class as I would like to 211 | have one .i file by OCC package. 212 | 213 | 2006-10-23 15:00:47 tag V0_13_2 214 | 215 | 2006-10-23 15:00:47 Denis Barbier 216 | 217 | * src/GeomLProp_SLProps.i: 218 | Really fix GLProp_SLProp::normal 219 | 220 | 2006-04-07 14:03:35 tag V0_13_1 221 | 2006-04-07 14:03:35 tag V0_13 222 | 223 | 2006-04-07 14:03:35 Jerome Robert 224 | 225 | * src/GeomLProp_SLProps.i, src/gp.i: 226 | Fix a bug in GLProp_SLProp::normal which gave an error message when meshing a cone 227 | * src/Standard.i: Catch Opencascade exceptions. 228 | 229 | 2006-04-06 12:40:14 Jerome Robert 230 | 231 | * src/Geom.i, src/GeomLProp_SLProps.i, src/gp.i: 232 | Fix a bug Geom_Surface::Value. 233 | 234 | 2006-04-04 14:57:16 Jerome Robert 235 | 236 | * Makefile.am, autogen.sh, src/Makefile.am: 237 | Fix "make clean" 238 | * src/BRepTools.i: 239 | Port to Opencascade 6.1 240 | * src-java/test/Test3.java, src-java/test/Utilities.java: 241 | Add test for BRep_Builder.remove 242 | 243 | 2006-04-03 10:44:54 Denis Barbier 244 | 245 | * build.bat: 246 | Set VS80COMNTOOLS variable so that vcvars32.bat can be found 247 | 248 | 2006-03-31 17:07:13 Jerome Robert 249 | 250 | * build.bat: 251 | Add a batch script to build occjava from the command line on Windows. 252 | 253 | 2006-03-30 12:10:49 tag V0_12_2 254 | 255 | 2006-03-30 12:10:49 Jerome Robert 256 | 257 | * configure.ac, src/TopoDS.i: 258 | Fix bug 1460763: Free edges crash 259 | 260 | 2006-03-23 14:37:32 tag V0_12_1 261 | 262 | 2006-03-23 14:37:32 Jerome Robert 263 | 264 | * src/GeomLProp_SLProps.i: 265 | [bug 1452435] No deflection parameter with jCAE 0.11. See https://sourceforge.net/tracker/?func=detail&atid=540660&aid=1452435&group_id=74334 . 266 | 267 | 2006-03-01 17:55:36 tag V0_12 268 | 269 | 2006-03-01 17:55:36 Jerome Robert 270 | 271 | * occjava-swig.vcproj: 272 | In Windows compilation, remove dependency to msvcr80.dll and disable CLR. 273 | 274 | 2006-02-27 18:04:42 Jerome Robert 275 | 276 | * runTests.sh, src/, src-java: 277 | Add "make solid" and "make wire from a TopTool_ListOfShape". Move Example1 to src-java/test. 278 | 279 | 2006-02-23 15:06:07 Jerome Robert 280 | 281 | * Swig.rules, occjava-swig.vcproj: 282 | Add files to compile on Windows 283 | 284 | * acsite.m4, configure.ac: 285 | Add autodetection of JNI and swig 286 | 287 | * src/BRep_Tool.i, src/Geom.i, src/GeomLProp_SLProps.i, src/OccJava.i: 288 | Use Handle with Geom* objects. Looks like there is no way to avoid that. 289 | 290 | 2006-02-22 14:05:18 Jerome Robert 291 | 292 | * doc/Example1.java, src/BRepBuilderAPI.i src/BRepPrimAPI.i 293 | src/BRepTools.i src/Makefile.am src/OccJava.i src/TopoDS.i: 294 | Add many classes and an example of BRepBuilderAPI 295 | 296 | 2006-02-21 16:01:23 Jerome Robert 297 | 298 | * src/Makefile.am, src/OccJava.i, src/TopoDS.i, src/TopoDS_Shape.i: 299 | rename TopoDS_Shape.i to TopoDS.i 300 | 301 | 2006-02-20 15:42 tag V0_11 302 | 303 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | OccJava is a Java wrapper for a small subset of Opencascade libraries 2 | based on swig (www.swig.org). 3 | 4 | This library is needed to run the CAD module of jCAE. It require Swig, 5 | CMake, OCCT (http://www.opencascade.org) or OCE (https://github.com/tpaviot/oce). 6 | 7 | Swig and CMake can be installed on Debian/ubuntu with: 8 | apt-get install swig cmake 9 | 10 | Build OCE from source (https://github.com/tpaviot/oce/wiki/Build) or install OCCT. 11 | If you build OCE you can disable X11 support in CMakeCache.txt: 12 | OCE_DISABLE_X11:BOOL=ON 13 | 14 | Then to build occjava: 15 | 16 | $ mkdir occjava-linux-build 17 | $ cd occjava-linux-build 18 | $ cmake -DOCE_DIR=/path/to/oce/lib/oce-0.7.0-dev /path/to/occjava (for OCE) 19 | or 20 | $ cmake -DOCC_INCLUDE_PATH=/path/to/occt/inc -DOCC_LIB=/path/to/occt/lib /path/to/occjava 21 | $ make 22 | 23 | Build the jcae-sources/jcae/occjava project from netbeans 24 | If you intend to build the occjava netbeans module set path.occ.linux and path.occ.win32 25 | in jcae/nbproject/private/private.properties to /path/to/occjava-linux-build/libOccJava.so 26 | and /path/to/occjava-win32-build/OccJava.dll 27 | 28 | About OCE and OCCT 29 | ------------------ 30 | jCAE developers now use OCE and no longer test OccJava with OCCT. Anyway as OCE and OCCT 31 | are very close OccJava should keep working with both. 32 | 33 | Mixing libstdc++5 and libstdc++6 (outdated) 34 | -------------------------------- 35 | Starting from version 0.14.1+r1221 (2007-05-10), using the same g++ version for 36 | OpenCASCADE and occjava is required. This is due to the addition of STL iostream 37 | binding. The official binaries of OpenCASCADE 6.2 are built with g++-3.3. If 38 | you get this compilation warning: 39 | ld: warning: libstdc++.so.5, needed by XXXXXX, may conflict with libstdc++.so.6 40 | occjava will crash as soon as you will use the iostream binding. 41 | 42 | Note (outdated) 43 | ---- 44 | The wrapper may not compile properly with -O2. -fno-strict-aliasing 45 | is required with -O2. See: 46 | http://sourceforge.net/mailarchive/forum.php?thread_id=9715058&forum_id=46758 47 | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21920 48 | 49 | How to add class and methods (draft) 50 | ---------------------------- 51 | - Find the src/*.i file you want to modify or add a new one (grep ;) ) 52 | - Copy method/class definition from Opencascade header 53 | - For Geom_Geometry and Geom2d_Geometry: Change Handle(aType) to Handle_aType 54 | 55 | Required OpenCASCADE libraries (probably outdated) 56 | ------------------------------ 57 | The whole OpenCASCADE bundle is not require to use OccJava. Here is the list 58 | of required libraries. 59 | 60 | On Linux: 61 | libTKBO.so 62 | libTKBRep.so 63 | libTKernel.so 64 | libTKFillet.so 65 | libTKG2d.so 66 | libTKG3d.so 67 | libTKGeomAlgo.so 68 | libTKGeomBase.so 69 | libTKIGES.so 70 | libTKMath.so 71 | libTKMesh.so 72 | libTKOffset.so 73 | libTKPrim.so 74 | libTKShHealing.so 75 | libTKSTEP209.so 76 | libTKSTEPAttr.so 77 | libTKSTEPBase.so 78 | libTKSTEP.so 79 | libTKTopAlgo.so 80 | libTKV2d.so 81 | libTKV3d.so 82 | libTKXSBase.so 83 | 84 | On Windows: 85 | TKBO.dll 86 | TKBool.dll 87 | TKBRep.dll 88 | TKernel.dll 89 | TKFillet.dll 90 | TKG2d.dll 91 | TKG3d.dll 92 | TKGeomAlgo.dll 93 | TKGeomBase.dll 94 | TKIGES.dll 95 | TKMath.dll 96 | TKMesh.dll 97 | TKOffset.dll 98 | TKPrim.dll 99 | TKShHealing.dll 100 | TKSTEP209.dll 101 | TKSTEPAttr.dll 102 | TKSTEPBase.dll 103 | TKSTEP.dll 104 | TKTopAlgo.dll 105 | TKV2d.dll 106 | TKV3d.dll 107 | TKXSBase.dll 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OccJava - A SWIG-generated Java wrapper for OpenCascade 2 | 3 | This repository contains an extended version of the OccJava wrapper that is part of the Java Computer Aided Engineering project (https://github.com/jeromerobert/jCAE). 4 | 5 | An Ubuntu-related sequence of actions for building OccJava is: 6 | 7 | - Install required system dependencies: 8 | ``` 9 | sudo apt-get install git stow build-essential openjdk-7-jdk ant swig2.0 cmake 10 | ``` 11 | - Download and build OpenCascade Community Edition (OCE) 12 | ``` 13 | git clone git://github.com/tpaviot/oce.git ~/oce 14 | mkdir -p ~/oce/build 15 | cd ~/oce 16 | git checkout c0cdb53fdf7cc708eb303bec49b18e27edd7c74b 17 | cd ~/oce/build 18 | cmake -DOCE_INSTALL_PREFIX:PATH=/usr/local/stow/oce -DOCE_DRAW:BOOL=ON -DOCE_DISABLE_X11:BOOL=ON -DOCE_MULTITHREAD_LIBRARY:STRING=OPENMP .. 19 | make 20 | sudo make install/strip 21 | cd /usr/local/stow 22 | sudo stow oce 23 | ``` 24 | - Set required environmental variables, assuming bash shell: 25 | ``` 26 | echo 'export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64' >> ~/.bashrc 27 | echo 'export OCE_DIR=/usr/local/lib/oce-0.18-dev' >> ~/.bashrc 28 | echo 'export CASROOT=/usr/local' >> ~/.bashrc 29 | echo 'export MMGT_OPT=0' >> ~/.bashrc 30 | echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib/jni' >> ~/.bashrc 31 | source ~/.bashrc 32 | ``` 33 | - Build occjava (native part): 34 | ``` 35 | git clone https://github.com/OntoBREP/occjava.git ~/occjava 36 | mkdir -p ~/occjava/build 37 | cd ~/occjava/build 38 | cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/stow/occjava .. 39 | make 40 | sudo make install 41 | cd /usr/local/stow 42 | sudo stow occjava 43 | ``` 44 | - Build occjava (Java part): 45 | ``` 46 | cd ~/occjava/ 47 | ant 48 | ``` 49 | Done. The OccJava wrapper occjava.jar should reside in ~/occjava/lib. It depends on libOccJava.so and the OCE libs in /usr/local/lib. 50 | 51 | -------------------------------------------------------------------------------- /build-mingw: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # 4 | # On Debian install the g++-mingw-w64-i686 package, then set OCE_DIR 5 | # JAVA_DIR in this script, then run this script. 6 | # 7 | 8 | OCE_DIR=/home/robert/occ6.3/oce-win32-install/cmake 9 | JAVA_DIR=/home/robert/windows/jdk1.6.0_30 10 | BUILD_DIR=build-win32 11 | 12 | curDir=$PWD 13 | jcaeDir=$(dirname $0)/.. 14 | cd $jcaeDir 15 | jcaeDir=$PWD 16 | cd $curDir 17 | 18 | mkdir $BUILD_DIR 19 | cd $BUILD_DIR 20 | cmake -DOCE_DIR=$OCE_DIR \ 21 | -DCMAKE_TOOLCHAIN_FILE=$jcaeDir/vtk-util/toolchain-i686-w64-mingw32.cmake \ 22 | -DSWIG_DIR=/usr/bin \ 23 | -DSWIG_EXECUTABLE=/usr/bin/swig \ 24 | -DJAVA_AWT_LIBRARY=$JAVA_DIR/lib/jawt.lib \ 25 | -DJAVA_INCLUDE_PATH=$JAVA_DIR/include \ 26 | -DJAVA_INCLUDE_PATH2=$JAVA_DIR/include/win32 \ 27 | -DJAVA_JVM_LIBRARY=$JAVA_DIR/lib/jvm.lib \ 28 | -DJAVA_AWT_INCLUDE_PATH==$JAVA_DIR/include \ 29 | $jcaeDir/occjava 30 | make 31 | 32 | -------------------------------------------------------------------------------- /build.properties: -------------------------------------------------------------------------------- 1 | # Default properties to build occjava with ant 2 | # 3 | # Do not edit this file, but create a file build.private.properties 4 | # and redefine the properties you need in this file 5 | 6 | occjava.jar=lib/${project.name}.jar 7 | junit.jar=lib/junit4.jar 8 | 9 | # for j2se 5.0 10 | #compiler.arg=-Xlint -target 1.4 -source 1.4 11 | compiler.arg= 12 | ant.build.javac.source=5 13 | ant.build.javac.target=5 14 | 15 | classes.dir=classes 16 | build.dir=build 17 | classes.test.dir=classes-test 18 | src.dir=src-java 19 | src.test.dir=src-java-test 20 | test.dir=test 21 | javadoc.dir=doc/api 22 | project.name=${ant.project.name} 23 | test.jar=lib/${project.name}-test.jar 24 | test.jar.dependencies=${project.name}.jar jcae-viewer3d.jar 25 | 26 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | path_curr=$(pwd) 4 | path_base="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" 5 | path_nativelib="$path_base/build" 6 | 7 | printf "%b\n" "\n===============================" 8 | printf "%b\n" "| Cleaning project |" 9 | printf "%b\n" "===============================\n" 10 | 11 | ant -f "${path_base}/build.xml" clean 12 | returnCode=$? 13 | if [ $returnCode -ne 0 ];then 14 | exit 1; 15 | fi 16 | 17 | printf "%b\n" "\n===============================" 18 | printf "%b\n" "| Configuring occjava project |" 19 | printf "%b\n" "===============================\n" 20 | 21 | mkdir -p ${path_nativelib} 22 | cd ${path_nativelib} 23 | cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/stow/occjava .. 24 | returnCode=$? 25 | if [ $returnCode -ne 0 ];then 26 | exit 1; 27 | fi 28 | 29 | printf "%b\n" "\n===============================" 30 | printf "%b\n" "| Making occjava native lib |" 31 | printf "%b\n" "===============================\n" 32 | 33 | make 34 | returnCode=$? 35 | if [ $returnCode -ne 0 ];then 36 | exit 1; 37 | fi 38 | 39 | printf "%b\n" "\n===============================" 40 | printf "%b\n" "| Install occjava native lib |" 41 | printf "%b\n" "===============================\n" 42 | 43 | sudo make install 44 | returnCode=$? 45 | if [ $returnCode -ne 0 ];then 46 | exit 1; 47 | fi 48 | cd /usr/local/stow 49 | sudo stow occjava 50 | 51 | cd ${path_curr} 52 | printf "%b\n" "\n===============================" 53 | printf "%b\n" "| Building occjava JAR lib |" 54 | printf "%b\n" "===============================\n" 55 | 56 | ant -f "${path_base}/build.xml" 57 | returnCode=$? 58 | if [ $returnCode -ne 0 ];then 59 | exit 1; 60 | fi 61 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /doc/Example1.java: -------------------------------------------------------------------------------- 1 | import org.jcae.opencascade.jni.*; 2 | 3 | /** 4 | * Create a square with an attached free edge 5 | * @author Jerome Robert 6 | */ 7 | public class Example1 8 | { 9 | public static void main(String[] args) 10 | { 11 | // The plate 12 | double[] p1=new double[]{0, 0, 0}; 13 | double[] p2=new double[]{0, 1, 0}; 14 | double[] p3=new double[]{1, 1, 0}; 15 | double[] p4=new double[]{1, 0, 0}; 16 | double[] p5=new double[]{0.5, 0.5, 0}; 17 | double[] p6=new double[]{0.5, 0.5, 1}; 18 | 19 | TopoDS_Edge edge1=(TopoDS_Edge) new BRepBuilderAPI_MakeEdge(p1,p2).shape(); 20 | TopoDS_Edge edge2=(TopoDS_Edge) new BRepBuilderAPI_MakeEdge(p2,p3).shape(); 21 | TopoDS_Edge edge3=(TopoDS_Edge) new BRepBuilderAPI_MakeEdge(p3,p4).shape(); 22 | TopoDS_Edge edge4=(TopoDS_Edge) new BRepBuilderAPI_MakeEdge(p4,p1).shape(); 23 | 24 | TopoDS_Wire wirePlate= 25 | (TopoDS_Wire) new BRepBuilderAPI_MakeWire(edge1, edge2, edge3, edge4).shape(); 26 | 27 | TopoDS_Face face=(TopoDS_Face) new BRepBuilderAPI_MakeFace(wirePlate, true).shape(); 28 | 29 | // The wire 30 | TopoDS_Vertex vertex1=(TopoDS_Vertex) new BRepBuilderAPI_MakeVertex(p5).shape(); 31 | TopoDS_Vertex vertex2=(TopoDS_Vertex) new BRepBuilderAPI_MakeVertex(p6).shape(); 32 | TopoDS_Edge freeEdge=(TopoDS_Edge) new BRepBuilderAPI_MakeEdge(vertex1,vertex2).shape(); 33 | 34 | //Connect the wire to the plate 35 | BRep_Builder bb=new BRep_Builder(); 36 | bb.add(face, vertex1); 37 | 38 | //Put everything in a compound 39 | TopoDS_Compound compound=new TopoDS_Compound(); 40 | bb.makeCompound(compound); 41 | bb.add(compound, freeEdge); 42 | bb.add(compound, face); 43 | 44 | //Write to to a file 45 | BRepTools.write(compound, "/tmp/test.brep"); 46 | } 47 | } -------------------------------------------------------------------------------- /doc/runExample1.sh: -------------------------------------------------------------------------------- 1 | javac -classpath ../lib/occjava.jar Example1.java 2 | export MMGT_OPT=0 3 | LD_LIBRARY_PATH=../src/.libs/:$CASROOT/Linux/lib/ java -classpath ../lib/occjava.jar:. Example1 4 | -------------------------------------------------------------------------------- /occ-BRepMesh_FastDiscret.patch: -------------------------------------------------------------------------------- 1 | This patch is for Opencascade 6.3. The bug is fixed in Opencascade 6.5. 2 | 3 | diff --git a/ros/src/BRepMesh/BRepMesh_FastDiscret.cxx b/ros/src/BRepMesh/BRepMesh_FastDiscret.cxx 4 | index 9ec6e90..9dc10bc 100644 5 | --- a/ros/src/BRepMesh/BRepMesh_FastDiscret.cxx 6 | +++ b/ros/src/BRepMesh/BRepMesh_FastDiscret.cxx 7 | @@ -443,8 +443,11 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface) 8 | 9 | //clear the structure of links 10 | const MeshDS_MapOfInteger& aLinks = structure->LinkOfDomain(nbDomains); 11 | + TColStd_SequenceOfInteger toRemove; 12 | for(MeshDS_MapOfInteger::Iterator anIter(aLinks);anIter.More();anIter.Next()) 13 | - structure->ForseRemoveLink(anIter.Key()); 14 | + toRemove.Append(anIter.Key()); 15 | + for (i = 1; i <= toRemove.Length(); i++) 16 | + structure->ForseRemoveLink(toRemove.Value(i)); 17 | for (i = 1; i <= myvemap.Extent(); i++) 18 | structure->ForseRemoveNode(myvemap.FindKey(i)); 19 | 20 | -------------------------------------------------------------------------------- /occ-BRepMesh_FastDiscretFace.patch: -------------------------------------------------------------------------------- 1 | This patch is for Opencascade 6.5. 2 | See http://www.opencascade.org/org/forum/thread_20076/ 3 | 4 | diff --git a/ros/src/BRepMesh/BRepMesh_FastDiscretFace.cxx b/ros/src/BRepMesh/BRepMesh_FastDiscretFace.cxx 5 | index 8f96927..e0f5684 100644 6 | --- a/ros/src/BRepMesh/BRepMesh_FastDiscretFace.cxx 7 | +++ b/ros/src/BRepMesh/BRepMesh_FastDiscretFace.cxx 8 | @@ -936,7 +936,7 @@ void BRepMesh_FastDiscretFace::InternalVertices ( const Handle(BRepAdaptor_HSurf 9 | } 10 | } 11 | } 12 | - else if (thetype == GeomAbs_BezierSurface || thetype == GeomAbs_BSplineSurface) 13 | + else if (false) 14 | { 15 | Standard_Integer i, j; 16 | 17 | -------------------------------------------------------------------------------- /occ-mingw-makefile.patch: -------------------------------------------------------------------------------- 1 | diff --git a/.gitignore b/.gitignore 2 | new file mode 100644 3 | index 0000000..f045603 4 | --- /dev/null 5 | +++ b/.gitignore 6 | @@ -0,0 +1,80 @@ 7 | +.pc 8 | +*.o 9 | +*.class 10 | +*.a 11 | +*.dll 12 | +ros/adm/mingw/FWOSPlugin/ 13 | +ros/adm/mingw/PTKernel/ 14 | +ros/adm/mingw/TKAdvTools/ 15 | +ros/adm/mingw/TKBO/ 16 | +ros/adm/mingw/TKBRep/ 17 | +ros/adm/mingw/TKBin/ 18 | +ros/adm/mingw/TKBinL/ 19 | +ros/adm/mingw/TKBinTObj/ 20 | +ros/adm/mingw/TKBinXCAF/ 21 | +ros/adm/mingw/TKBool/ 22 | +ros/adm/mingw/TKCAF/ 23 | +ros/adm/mingw/TKCDF/ 24 | +ros/adm/mingw/TKCDLFront/ 25 | +ros/adm/mingw/TKCPPClient/ 26 | +ros/adm/mingw/TKCPPExt/ 27 | +ros/adm/mingw/TKCPPIntExt/ 28 | +ros/adm/mingw/TKCPPJini/ 29 | +ros/adm/mingw/TKCSFDBSchema/ 30 | +ros/adm/mingw/TKDCAF/ 31 | +ros/adm/mingw/TKDraw/ 32 | +ros/adm/mingw/TKFeat/ 33 | +ros/adm/mingw/TKFillet/ 34 | +ros/adm/mingw/TKG2d/ 35 | +ros/adm/mingw/TKG3d/ 36 | +ros/adm/mingw/TKGeomAlgo/ 37 | +ros/adm/mingw/TKGeomBase/ 38 | +ros/adm/mingw/TKHLR/ 39 | +ros/adm/mingw/TKIDLFront/ 40 | +ros/adm/mingw/TKIGES/ 41 | +ros/adm/mingw/TKLCAF/ 42 | +ros/adm/mingw/TKMath/ 43 | +ros/adm/mingw/TKMesh/ 44 | +ros/adm/mingw/TKMeshVS/ 45 | +ros/adm/mingw/TKNIS/ 46 | +ros/adm/mingw/TKOffset/ 47 | +ros/adm/mingw/TKOpenGl/ 48 | +ros/adm/mingw/TKPCAF/ 49 | +ros/adm/mingw/TKPLCAF/ 50 | +ros/adm/mingw/TKPShape/ 51 | +ros/adm/mingw/TKPrim/ 52 | +ros/adm/mingw/TKSTEP/ 53 | +ros/adm/mingw/TKSTEP209/ 54 | +ros/adm/mingw/TKSTEPAttr/ 55 | +ros/adm/mingw/TKSTEPBase/ 56 | +ros/adm/mingw/TKSTL/ 57 | +ros/adm/mingw/TKService/ 58 | +ros/adm/mingw/TKShHealing/ 59 | +ros/adm/mingw/TKShapeSchema/ 60 | +ros/adm/mingw/TKStdLSchema/ 61 | +ros/adm/mingw/TKStdSchema/ 62 | +ros/adm/mingw/TKTCPPExt/ 63 | +ros/adm/mingw/TKTObj/ 64 | +ros/adm/mingw/TKTObjDRAW/ 65 | +ros/adm/mingw/TKTopAlgo/ 66 | +ros/adm/mingw/TKTopTest/ 67 | +ros/adm/mingw/TKV2d/ 68 | +ros/adm/mingw/TKV3d/ 69 | +ros/adm/mingw/TKVRML/ 70 | +ros/adm/mingw/TKViewerTest/ 71 | +ros/adm/mingw/TKWOK/ 72 | +ros/adm/mingw/TKWOKTcl/ 73 | +ros/adm/mingw/TKXCAF/ 74 | +ros/adm/mingw/TKXCAFSchema/ 75 | +ros/adm/mingw/TKXDEDRAW/ 76 | +ros/adm/mingw/TKXDEIGES/ 77 | +ros/adm/mingw/TKXDESTEP/ 78 | +ros/adm/mingw/TKXMesh/ 79 | +ros/adm/mingw/TKXSBase/ 80 | +ros/adm/mingw/TKXSDRAW/ 81 | +ros/adm/mingw/TKXml/ 82 | +ros/adm/mingw/TKXmlL/ 83 | +ros/adm/mingw/TKXmlTObj/ 84 | +ros/adm/mingw/TKXmlXCAF/ 85 | +ros/adm/mingw/TKjcas/ 86 | +ros/mingw/ 87 | diff --git a/ros/adm/mingw/Makefile b/ros/adm/mingw/Makefile 88 | new file mode 100644 89 | index 0000000..6350613 90 | --- /dev/null 91 | +++ b/ros/adm/mingw/Makefile 92 | @@ -0,0 +1,34 @@ 93 | +all: 94 | + ./pywok.py 95 | + $(MAKE) -C TKernel 96 | + $(MAKE) -C TKMath 97 | + $(MAKE) -C TKAdvTools 98 | + $(MAKE) -C TKG2d 99 | + $(MAKE) -C TKG3d 100 | + $(MAKE) -C TKGeomBase 101 | + $(MAKE) -C TKBRep 102 | + $(MAKE) -C TKGeomAlgo 103 | + $(MAKE) -C TKTopAlgo 104 | + $(MAKE) -C TKPrim 105 | + $(MAKE) -C TKBO 106 | + $(MAKE) -C TKHLR 107 | + $(MAKE) -C TKMesh 108 | + $(MAKE) -C TKShHealing 109 | + $(MAKE) -C TKBool 110 | + $(MAKE) -C TKXMesh 111 | + $(MAKE) -C TKFillet 112 | + $(MAKE) -C TKFeat 113 | + $(MAKE) -C TKOffset 114 | + $(MAKE) -C TKXSBase 115 | + $(MAKE) -C TKSTEPBase 116 | + $(MAKE) -C TKSTEPAttr 117 | + $(MAKE) -C TKSTEP209 118 | + $(MAKE) -C TKSTEP 119 | + $(MAKE) -C TKIGES 120 | + $(MAKE) -C TKService 121 | + $(MAKE) -C TKV2d 122 | + $(MAKE) -C TKV3d 123 | + 124 | +clean: 125 | + rm -rf OCCMingw*.class TKernel FWOSPlugin PTKernel TKAdvTools TKBO TKBRep TKBin TKBinL TKBinTObj TKBinXCAF TKBool TKCAF TKCDF TKCDLFront TKCPPClient TKCPPExt TKCPPIntExt TKCPPJini TKCSFDBSchema TKDCAF TKDraw TKFeat TKFillet TKG2d TKG3d TKGeomAlgo TKGeomBase TKHLR TKIDLFront TKIGES TKLCAF TKMath TKMesh TKMeshVS TKNIS TKOffset TKOpenGl TKPCAF TKPLCAF TKPShape TKPrim TKSTEP TKSTEP209 TKSTEPAttr TKSTEPBase TKSTL TKService TKShHealing TKShapeSchema TKStdLSchema TKStdSchema TKTCPPExt TKTObj TKTObjDRAW TKTopAlgo TKTopTest TKV2d TKV3d TKVRML TKViewerTest TKWOK TKWOKTcl TKXCAF TKXCAFSchema TKXDEDRAW TKXDEIGES TKXDESTEP TKXMesh TKXSBase TKXSDRAW TKXml TKXmlL TKXmlTObj TKXmlXCAF TKjcas 126 | + 127 | diff --git a/ros/adm/mingw/header.mk b/ros/adm/mingw/header.mk 128 | new file mode 100644 129 | index 0000000..ee3efb7 130 | --- /dev/null 131 | +++ b/ros/adm/mingw/header.mk 132 | @@ -0,0 +1,40 @@ 133 | +CC := i586-mingw32msvc-gcc 134 | +CXX := i586-mingw32msvc-g++ 135 | +CASROOT := ../../.. 136 | +DRV := $(CASROOT)/drv 137 | +SRC := $(CASROOT)/src 138 | +BIN := $(CASROOT)/mingw/bin 139 | +LIB := $(CASROOT)/mingw/lib 140 | +CPPFLAGS := -I$(CASROOT)/inc/ -DWNT -D__MATH_WNT_H -DHAVE_NO_DLL 141 | +CXXFLAGS := -O2 -march=pentium3 -fno-strict-aliasing 142 | +LDFLAGS := -shared -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -Wl,-export-all-symbols 143 | +TKernelFLAGS := -lwinspool -lws2_32 -lgdi32 144 | +TKMathFLAGS := -lTKernel 145 | +TKAdvToolsFLAGS := -lTKernel 146 | +TKG2dFLAGS := -lTKernel -lTKMath 147 | +TKG3dFLAGS := -lTKernel -lTKG2d -lTKMath 148 | +TKGeomBaseFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath 149 | +TKBRepFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase 150 | +TKGeomAlgoFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKBRep 151 | +TKTopAlgoFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKGeomAlgo -lTKBRep 152 | +TKPrimFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKTopAlgo -lTKBRep 153 | +TKHLRFLAGS := -lTKernel -lTKGeomBase -lTKG3d -lTKTopAlgo -lTKMath -lTKGeomAlgo -lTKBRep -lTKG2d 154 | +TKBOFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKTopAlgo -lTKBRep -lTKGeomAlgo 155 | +TKMeshFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKTopAlgo -lTKBRep -lTKGeomAlgo 156 | +TKShHealingFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKTopAlgo -lTKBRep -lTKGeomAlgo 157 | +TKBoolFLAGS := -lTKernel -lTKGeomAlgo -lTKG3d -lTKShHealing -lTKGeomBase -lTKTopAlgo -lTKMath -lTKBO -lTKG2d -lTKBRep -lTKPrim 158 | +TKXMeshFLAGS := -lTKernel -lTKG2d -lTKMath -lTKMesh 159 | +TKFilletFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKTopAlgo -lTKBRep -lTKGeomAlgo -lTKBool 160 | +TKFeatFLAGS := -lTKernel -lTKG2d -lTKG3d -lTKMath -lTKGeomBase -lTKTopAlgo -lTKBRep -lTKGeomAlgo -lTKBO -lTKPrim -lTKBool 161 | +TKOffsetFLAGS := -lTKBool -lTKGeomAlgo -lTKernel -lTKGeomBase -lTKTopAlgo -lTKMath -lTKBO -lTKG2d -lTKG3d -lTKBRep -lTKShHealing -lTKFillet -lTKPrim 162 | +TKXSBaseFLAGS := -lTKernel -lTKMath -lTKG2d -lTKG3d -lTKShHealing -lTKBRep -lTKGeomBase -lTKTopAlgo 163 | +TKSTEPBaseFLAGS := -lTKernel -lTKXSBase -lTKMath 164 | +TKSTEPFLAGS := -lTKernel -lTKXSBase -lTKSTEPBase -lTKSTEPAttr -lTKMath -lTKG3d -lTKG2d -lTKShHealing -lTKSTEP209 -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo -lws2_32 165 | +TKIGESFLAGS := -lTKernel -lTKXSBase -lTKSTEPBase -lTKSTEPAttr -lTKMath -lTKG3d -lTKG2d -lTKShHealing -lTKSTEP209 -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo -lTKPrim -lTKBool 166 | +TKSTEPAttrFLAGS := -lTKSTEPBase -lTKernel -lTKXSBase 167 | +TKSTEP209FLAGS := -lTKSTEPBase -lTKernel -lTKXSBase 168 | +TKServiceFLAGS := -lTKernel -lTKMath -lgdi32 -lwinspool 169 | +TKV2dFLAGS := -lTKernel -lTKService -lTKG3d -lTKTopAlgo -lTKMath -lTKBRep -lTKGeomBase -lTKG2d -lTKHLR -lTKGeomAlgo 170 | +TKV3dFLAGS := -lTKernel -lTKG3d -lTKTopAlgo -lTKGeomBase -lTKService -lTKMath -lTKMesh -lTKGeomAlgo -lTKHLR -lTKBRep -lTKG2d -lTKV2d -lcomdlg32 -lgdi32 171 | + 172 | + 173 | diff --git a/ros/adm/mingw/pywok.py b/ros/adm/mingw/pywok.py 174 | new file mode 100755 175 | index 0000000..3c7bc25 176 | --- /dev/null 177 | +++ b/ros/adm/mingw/pywok.py 178 | @@ -0,0 +1,95 @@ 179 | +#! /usr/bin/python 180 | + 181 | +# Use of EXTERNLIB is currently disabled because TKernel/EXTERNLIB 182 | +# contains strings which are not libs 183 | + 184 | +import os 185 | + 186 | +def parse_list(pdir, key): 187 | + pfile = os.path.join(pdir, key) 188 | + toreturn=[] 189 | + try: 190 | + f = open(pfile) 191 | + for l in f: 192 | + s = l.strip() 193 | + if len(s)>0: 194 | + toreturn.append(s) 195 | + f.close() 196 | + except IOError: 197 | + pass 198 | + return toreturn 199 | + 200 | +def to_ld_param(libs): 201 | + toreturn=[] 202 | + for l in libs: 203 | + toreturn.append(" -l"+l) 204 | + return " ".join(toreturn) 205 | + 206 | +def create_makefile(name, packages, externlibs): 207 | + try: 208 | + os.mkdir(name) 209 | + except OSError: 210 | + pass 211 | + 212 | + out=open(os.path.join(name, "Makefile"), "w") 213 | + 214 | + try: 215 | + packages.remove("Xw") 216 | + except ValueError: 217 | + pass 218 | + 219 | + try: 220 | + packages.remove("ImageUtility") 221 | + except ValueError: 222 | + pass 223 | + 224 | + out.write("include ../header.mk\n") 225 | + 226 | + for p in packages: 227 | + out.write(""" 228 | +objects += $(patsubst %%.cxx,%%.o,$(notdir $(wildcard $(SRC)/%s/*.cxx))) 229 | +objects += $(patsubst %%.c,%%.o,$(notdir $(wildcard $(SRC)/%s/*.c))) 230 | +objects += $(patsubst %%.cxx,%%.o,$(notdir $(wildcard $(DRV)/%s/*.cxx))) 231 | +objects += $(patsubst %%.c,%%.o,$(notdir $(wildcard $(DRV)/%s/*.c))) 232 | +""" % (p,p,p,p)) 233 | + 234 | + for p in packages: 235 | + out.write(""" 236 | +%%.o : $(SRC)/%s/%%.cxx 237 | + $(CXX) $(CPPFLAGS) -I$(DRV)/%s -I$(SRC)/%s -c $(CXXFLAGS) -o $@ $< 238 | +%%.o : $(DRV)/%s/%%.cxx 239 | + $(CXX) $(CPPFLAGS) -I$(DRV)/%s -I$(SRC)/%s -c $(CXXFLAGS) -o $@ $< 240 | +%%.o : $(SRC)/%s/%%.c 241 | + $(CC) $(CPPFLAGS) -I$(DRV)/%s -I$(SRC)/%s -c $(CFLAGS) -o $@ $< 242 | +%%.o : $(DRV)/%s/%%.c 243 | + $(CC) $(CPPFLAGS) -I$(DRV)/%s -I$(SRC)/%s -c $(CFLAGS) -o $@ $< 244 | +""" % (p,p,p, p,p,p, p,p,p, p,p,p)) 245 | + 246 | + out.write(""" 247 | +$(BIN)/%s.dll : $(objects) 248 | + mkdir -p $(LIB) $(BIN) 249 | + $(CXX) $(LDFLAGS) -L$(LIB) -o $@ $^ $(%sFLAGS) -Wl,--out-implib,$(LIB)/lib%s.a 250 | +""" % (name, name, name)) 251 | + out.close(); 252 | + 253 | +def search_libs(package, libdict): 254 | + try: 255 | + l=libdict[package] 256 | + except KeyError: 257 | + l=[] 258 | + toreturn=[] 259 | + toreturn.extend(l) 260 | + for p in l: 261 | + toreturn.extend(search_libs(p, libdict)) 262 | + return toreturn 263 | + 264 | +externlibs={} 265 | +packages={} 266 | +for dir in os.listdir("../../src"): 267 | + pdir = os.path.join("../../src", dir) 268 | + packages[dir]=parse_list(pdir, "PACKAGES") 269 | + externlibs[dir]=parse_list(pdir, "EXTERNLIB") 270 | + 271 | +for dir, plist in packages.iteritems(): 272 | + if len(plist)>0: 273 | + create_makefile(dir, plist, search_libs(dir, externlibs)) 274 | -------------------------------------------------------------------------------- /occ-mingw-port.patch: -------------------------------------------------------------------------------- 1 | diff --git a/ros/inc/Handle_Standard_Transient.hxx b/ros/inc/Handle_Standard_Transient.hxx 2 | index 0500103..e3c6202 100644 3 | --- a/ros/inc/Handle_Standard_Transient.hxx 4 | +++ b/ros/inc/Handle_Standard_Transient.hxx 5 | @@ -13,7 +13,7 @@ 6 | #include 7 | #endif 8 | 9 | -#ifdef _WIN32 10 | +#ifdef _MSC_VER 11 | // Disable the warning "conversion from 'unsigned int' to Standard_Transient *" 12 | #pragma warning (push) 13 | #pragma warning (disable:4312) 14 | @@ -228,7 +228,7 @@ private: 15 | Standard_Transient *entity; 16 | }; 17 | 18 | -#ifdef _WIN32 19 | +#ifdef _MSC_VER 20 | #pragma warning (pop) 21 | #endif 22 | 23 | diff --git a/ros/inc/Standard_Atomic.hxx b/ros/inc/Standard_Atomic.hxx 24 | index 4842877..73adc8b 100644 25 | --- a/ros/inc/Standard_Atomic.hxx 26 | +++ b/ros/inc/Standard_Atomic.hxx 27 | @@ -24,7 +24,7 @@ 28 | //=================================================== 29 | // Windows NT, MSVC++ compiler 30 | //=================================================== 31 | -#if defined(WNT) 32 | +#if defined(_MSC_VER) 33 | 34 | extern "C" { 35 | long _InterlockedIncrement(long volatile* lpAddend); 36 | diff --git a/ros/inc/Standard_CString.hxx b/ros/inc/Standard_CString.hxx 37 | index a1caadf..f003f8c 100644 38 | --- a/ros/inc/Standard_CString.hxx 39 | +++ b/ros/inc/Standard_CString.hxx 40 | @@ -13,7 +13,7 @@ 41 | # include 42 | # endif 43 | 44 | -# ifdef WNT 45 | +# ifdef _MSC_VER 46 | # define strcasecmp _stricmp 47 | # endif 48 | 49 | diff --git a/ros/inc/Standard_Macro.hxx b/ros/inc/Standard_Macro.hxx 50 | index 0df32b7..852d8c2 100644 51 | --- a/ros/inc/Standard_Macro.hxx 52 | +++ b/ros/inc/Standard_Macro.hxx 53 | @@ -125,7 +125,4 @@ 54 | //# endif // WNT 55 | # endif // __Standard_API 56 | 57 | -// Define _OCC64 variable (unless already defined) if platform is known to be 64-bit 58 | -#include 59 | - 60 | #endif 61 | diff --git a/ros/inc/Standard_values.h b/ros/inc/Standard_values.h 62 | index 623800a..bc78d2e 100644 63 | --- a/ros/inc/Standard_values.h 64 | +++ b/ros/inc/Standard_values.h 65 | @@ -31,6 +31,10 @@ Facility : CAS-CADE V1.3A 66 | # include 67 | #endif 68 | 69 | +#ifdef __MINGW32__ 70 | +# include 71 | +#endif 72 | + 73 | #if defined (__hpux) || defined (HPUX) 74 | # ifdef MAXINT 75 | # undef MAXINT 76 | diff --git a/ros/src/MFT/MFT_FontManager.cxx b/ros/src/MFT/MFT_FontManager.cxx 77 | index 5820d62..238c58c 100644 78 | --- a/ros/src/MFT/MFT_FontManager.cxx 79 | +++ b/ros/src/MFT/MFT_FontManager.cxx 80 | @@ -148,6 +148,9 @@ 81 | // -- Category: Local structures 82 | // -------------------------------- 83 | 84 | +#ifdef __MINGW32__ 85 | + #define DrawTextA DrawText 86 | +#endif 87 | 88 | #define MFT_COMMANDBUFFERSIZE 512 89 | typedef struct _MFT_CommandBuffer { 90 | diff --git a/ros/src/OSD/OSD.cxx b/ros/src/OSD/OSD.cxx 91 | index 58e75b1..e1b133a 100644 92 | --- a/ros/src/OSD/OSD.cxx 93 | +++ b/ros/src/OSD/OSD.cxx 94 | @@ -99,7 +99,7 @@ Standard_Boolean OSD::CStringToReal(const Standard_CString aString, 95 | //======================================================================= 96 | 97 | #ifdef WNT 98 | -# include 99 | +# include 100 | #if !defined(__CYGWIN32__) && !defined(__MINGW32__) 101 | # include 102 | #endif 103 | diff --git a/ros/src/OSD/OSD_Process.cxx b/ros/src/OSD/OSD_Process.cxx 104 | index 8b01231..6eeb9b3 100644 105 | --- a/ros/src/OSD/OSD_Process.cxx 106 | +++ b/ros/src/OSD/OSD_Process.cxx 107 | @@ -202,7 +202,7 @@ Standard_Integer OSD_Process::Error()const{ 108 | #include 109 | 110 | #include 111 | -#include /// pour UNLEN ( see MSDN about GetUserName() ) 112 | +#include /// pour UNLEN ( see MSDN about GetUserName() ) 113 | 114 | 115 | #pragma warning( disable : 4700 ) 116 | diff --git a/ros/src/OSD/OSD_signal_WNT.cxx b/ros/src/OSD/OSD_signal_WNT.cxx 117 | index 89a67a1..a21df90 100644 118 | --- a/ros/src/OSD/OSD_signal_WNT.cxx 119 | +++ b/ros/src/OSD/OSD_signal_WNT.cxx 120 | @@ -550,8 +550,10 @@ static LONG __fastcall _osd_raise ( DWORD dwCode, LPTSTR msg ) 121 | case EXCEPTION_FLT_INVALID_OPERATION: 122 | case EXCEPTION_FLT_DENORMAL_OPERAND: 123 | case EXCEPTION_FLT_INEXACT_RESULT: 124 | +#ifdef _MSC_VER 125 | case STATUS_FLOAT_MULTIPLE_TRAPS: 126 | case STATUS_FLOAT_MULTIPLE_FAULTS: 127 | +#endif 128 | Standard_NumericError :: Raise ( msg ); 129 | default: 130 | break; 131 | diff --git a/ros/src/Standard/Standard_MMgrOpt.cxx b/ros/src/Standard/Standard_MMgrOpt.cxx 132 | index c170bbd..0be6e25 100644 133 | --- a/ros/src/Standard/Standard_MMgrOpt.cxx 134 | +++ b/ros/src/Standard/Standard_MMgrOpt.cxx 135 | @@ -846,7 +846,7 @@ void Standard_MMgrOpt::FreeMemory (Standard_Address aBlock, 136 | // recover handle to the memory mapping stored just before the block 137 | const HANDLE * aMBlock = (const HANDLE *)aBlock; 138 | HANDLE hMap = *(--aMBlock); 139 | - UnmapViewOfFile((LPCVOID)aMBlock); 140 | + UnmapViewOfFile(const_cast((LPCVOID)aMBlock)); 141 | CloseHandle (hMap); 142 | #endif 143 | } 144 | diff --git a/ros/src/WNT/EHDC.cxx b/ros/src/WNT/EHDC.cxx 145 | index 75dd8f2..a184cec 100644 146 | --- a/ros/src/WNT/EHDC.cxx 147 | +++ b/ros/src/WNT/EHDC.cxx 148 | @@ -8,6 +8,11 @@ 149 | 150 | #include 151 | #include 152 | +#ifdef __MINGW32__ 153 | + #include 154 | + #include 155 | + #define min(a,b) ((a)<(b)?(a):(b)) 156 | +#endif 157 | 158 | #define ROUNDL( d ) ( LONG )( ( d ) + 0.5 ) 159 | #define Y( y ) ( mySize.cy - ( y ) ) 160 | @@ -33,6 +38,8 @@ static void WINAPI _XFORMApplyf ( PFPOINT, int, PXFORM ); 161 | static void WINAPI _RenderPath ( HDC, LPPOINT, PBYTE, int ); 162 | static int WINAPI _TextPath ( HDC, int, int, void*, LPPOINT, PBYTE, int, PSIZE, BOOL ); 163 | 164 | +VOID CALLBACK ___auxDDAF ( int x, int y, LPARAM lpParam ); 165 | + 166 | EHDC :: EHDC ( HDC hdc, PSIZE szClient ) { 167 | 168 | _Init (); 169 | diff --git a/ros/src/WNT/W32_Allocator.hxx b/ros/src/WNT/W32_Allocator.hxx 170 | index abdf9eb..33dadcb 100644 171 | --- a/ros/src/WNT/W32_Allocator.hxx 172 | +++ b/ros/src/WNT/W32_Allocator.hxx 173 | @@ -101,7 +101,6 @@ struct W32_Note { // base class to represent graphic object 174 | 175 | #ifdef OCC5415 176 | void operator delete (void*, W32_Allocator*) {} 177 | -private: // to protect against possible accidental usage 178 | void operator delete (void* p) {} 179 | #endif 180 | }; 181 | diff --git a/ros/src/WNT/W95_Allocator.cxx b/ros/src/WNT/W95_Allocator.cxx 182 | index d1501e1..855c7dc 100644 183 | --- a/ros/src/WNT/W95_Allocator.cxx 184 | +++ b/ros/src/WNT/W95_Allocator.cxx 185 | @@ -13,6 +13,13 @@ 186 | #include 187 | #include 188 | 189 | +#ifdef __MINGW32__ 190 | + #include 191 | + #include 192 | + #define min(a,b) ((a)<(b)?(a):(b)) 193 | + #define max(a,b) ((a)>(b)?(a):(b)) 194 | +#endif 195 | + 196 | #define SGN( x ) ( ( x ) > 0 ? 1 : ( ( x ) < 0 ? -1 : 0 ) ) 197 | #define ALLOCATOR ( ( PW95_Allocator )myAllocator ) 198 | 199 | diff --git a/ros/src/WNT/WNT_Allocator.cxx b/ros/src/WNT/WNT_Allocator.cxx 200 | index 0f7b898..eeedb54 100644 201 | --- a/ros/src/WNT/WNT_Allocator.cxx 202 | +++ b/ros/src/WNT/WNT_Allocator.cxx 203 | @@ -16,6 +16,7 @@ 204 | #include 205 | 206 | #define ALLOCATOR ( ( PWNT_Allocator )myAllocator ) 207 | +#define max(a,b) ((a)>(b)?(a):(b)) 208 | 209 | static XFORM xfmIdent = { ( FLOAT )0.8660, ( FLOAT )0.5000, 210 | ( FLOAT )-0.5000, ( FLOAT )0.8660, 211 | diff --git a/ros/src/WNT/WNT_DDriver.cxx b/ros/src/WNT/WNT_DDriver.cxx 212 | index 9c98336..4099c9c 100644 213 | --- a/ros/src/WNT/WNT_DDriver.cxx 214 | +++ b/ros/src/WNT/WNT_DDriver.cxx 215 | @@ -102,7 +102,7 @@ static void __fastcall _dd_fill_buff ( char* ); 216 | static int __fastcall _dd_dev_size ( HDC, int ); 217 | 218 | static int CALLBACK _dd_enum_proc ( 219 | - HDC, HANDLETABLE FAR*, CONST ENHMETARECORD FAR*, 220 | + HDC, HANDLETABLE FAR*, ENHMETARECORD FAR*, 221 | int, LPARAM 222 | ); 223 | 224 | @@ -1983,7 +1983,7 @@ static int __fastcall _dd_dev_size ( HDC hdc, int index ) { 225 | static int CALLBACK _dd_enum_proc ( 226 | HDC hDC, 227 | HANDLETABLE FAR* lpHTable, 228 | - CONST ENHMETARECORD FAR* lpEMFR, 229 | + ENHMETARECORD FAR* lpEMFR, 230 | int nObj, 231 | LPARAM lpData 232 | ) { 233 | diff --git a/ros/src/WNT/WNT_IconBox.cxx b/ros/src/WNT/WNT_IconBox.cxx 234 | index d5565a3..f80699f 100644 235 | --- a/ros/src/WNT/WNT_IconBox.cxx 236 | +++ b/ros/src/WNT/WNT_IconBox.cxx 237 | @@ -30,7 +30,7 @@ WNT_IconBox :: WNT_IconBox ( 238 | ) : WNT_Window ( 239 | aDevice, aName, 240 | new WNT_WClass ( 241 | - "WNT_IconBoxClass", WNT_IconBoxWndProc, 242 | + "WNT_IconBoxClass", (void*)WNT_IconBoxWndProc, 243 | CS_HREDRAW | CS_VREDRAW 244 | ), 245 | aStyle | WS_VSCROLL, 246 | @@ -322,8 +322,10 @@ Standard_Boolean WNT_IconBox :: IconSize ( 247 | 248 | } // end for 249 | 250 | - return ( i > len ) ? Standard_False : 251 | - myImages -> Dim ( i, Width, Height ), Standard_True; 252 | + bool b = i <= len; 253 | + if(b) 254 | + myImages -> Dim ( i, Width, Height ); 255 | + return b; 256 | 257 | } // end WNT_IconBox :: IconSize 258 | //***// 259 | diff --git a/ros/src/WNT/WNT_ImageProcessor.cxx b/ros/src/WNT/WNT_ImageProcessor.cxx 260 | index 7809c05..7782e72 100644 261 | --- a/ros/src/WNT/WNT_ImageProcessor.cxx 262 | +++ b/ros/src/WNT/WNT_ImageProcessor.cxx 263 | @@ -49,6 +49,10 @@ 264 | #endif /* _DEBUG */ 265 | #define WINNT35X() (WNT_osVer.dwPlatformId == VER_PLATFORM_WIN32_NT && \ 266 | WNT_osVer.dwMajorVersion == 3 ) 267 | +#ifdef __MINGW32__ 268 | + #define __leave return Standard_False; 269 | + #define __finally catch(...) 270 | +#endif 271 | //***// 272 | typedef struct { 273 | 274 | diff --git a/ros/src/WNT/WNT_WClass.cxx b/ros/src/WNT/WNT_WClass.cxx 275 | index c2f1d87..44e64ff 100644 276 | --- a/ros/src/WNT/WNT_WClass.cxx 277 | +++ b/ros/src/WNT/WNT_WClass.cxx 278 | @@ -47,7 +47,7 @@ WNT_WClass::WNT_WClass ( 279 | 280 | lpszName = new char[ strlen ( aClassName ) + 1 ]; 281 | strcpy ( (Standard_PCharacter)lpszName, aClassName ); 282 | - lpfnWndProc = wc.lpfnWndProc; 283 | + lpfnWndProc = (void*)wc.lpfnWndProc; 284 | 285 | } // end constructor 286 | 287 | diff --git a/ros/src/WNT/WNT_Window.cxx b/ros/src/WNT/WNT_Window.cxx 288 | index a4bfca0..f1f71ab 100644 289 | --- a/ros/src/WNT/WNT_Window.cxx 290 | +++ b/ros/src/WNT/WNT_Window.cxx 291 | @@ -514,10 +514,10 @@ Aspect_TypeOfResize WNT_Window :: DoResize () const { 292 | 293 | if ( wp.showCmd != SW_SHOWMINIMIZED ) { 294 | 295 | - if ( Abs ( wp.rcNormalPosition.left - aXLeft ) > 2 ) mask |= 1; 296 | - if ( Abs ( wp.rcNormalPosition.right - aXRight ) > 2 ) mask |= 2; 297 | - if ( Abs ( wp.rcNormalPosition.top - aYTop ) > 2 ) mask |= 4; 298 | - if ( Abs ( wp.rcNormalPosition.bottom - aYBottom ) > 2 ) mask |= 8; 299 | + if ( Abs ( (Standard_Integer) (wp.rcNormalPosition.left - aXLeft) ) > 2 ) mask |= 1; 300 | + if ( Abs ( (Standard_Integer) (wp.rcNormalPosition.right - aXRight ) ) > 2 ) mask |= 2; 301 | + if ( Abs ( (Standard_Integer) (wp.rcNormalPosition.top - aYTop ) ) > 2 ) mask |= 4; 302 | + if ( Abs ( (Standard_Integer) (wp.rcNormalPosition.bottom - aYBottom) ) > 2 ) mask |= 8; 303 | 304 | switch ( mask ) { 305 | 306 | @@ -1207,7 +1207,7 @@ void WNT_Window :: doCreate ( 307 | 308 | if ( wProc != &WNT_WndProc ) { 309 | 310 | - myWndProc = wProc; 311 | + myWndProc = (void*)wProc; 312 | 313 | SetBackground ( aBackColor ); 314 | 315 | -------------------------------------------------------------------------------- /src-java-test/org/jcae/opencascade/jni/BRepBuilder.java: -------------------------------------------------------------------------------- 1 | package org.jcae.opencascade.jni; 2 | 3 | import org.jcae.opencascade.jni.*; 4 | 5 | import static org.junit.Assert.*; 6 | import org.junit.Test; 7 | 8 | /** 9 | * Show how to use brep builder 10 | * @author Jerome Robert 11 | */ 12 | public class BRepBuilder 13 | { 14 | @Test public void sample() 15 | { 16 | // Create a shape for the example (an half cone) 17 | double[] axis=new double[]{ 18 | 0,0,0, // position 19 | 0,0,1 // direction 20 | }; 21 | TopoDS_Shape cone=new BRepPrimAPI_MakeCone(axis, 2, 1, 1, Math.PI).shape(); 22 | 23 | // Now we will remove one face of the shape. We need first to find 24 | // the direct parent of this face. 25 | TopoDS_Iterator it=new TopoDS_Iterator(cone); 26 | 27 | // The children of solids are shells 28 | TopoDS_Shell shell = (TopoDS_Shell) it.value(); 29 | 30 | // Get a handle on the face to remove 31 | TopExp_Explorer exp=new TopExp_Explorer(cone, TopAbs_ShapeEnum.FACE); 32 | TopoDS_Face toRemove = (TopoDS_Face) exp.current(); 33 | exp.next(); 34 | TopoDS_Face anotherFace = (TopoDS_Face) exp.current(); 35 | 36 | // Remove the face 37 | BRep_Builder bb=new BRep_Builder(); 38 | bb.remove(shell, toRemove); 39 | 40 | // Let's revert the face and readd it to the cube 41 | bb.add(shell, toRemove.reversed()); 42 | 43 | // We can also create a compound containing only the 2 first faces of 44 | // the cone 45 | TopoDS_Compound compound=new TopoDS_Compound(); 46 | bb.makeCompound(compound); 47 | bb.add(compound, toRemove); 48 | bb.add(compound, anotherFace); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src-java-test/org/jcae/opencascade/jni/CircleExtrudeQuilt.java: -------------------------------------------------------------------------------- 1 | package org.jcae.opencascade.jni; 2 | 3 | import static org.junit.Assert.*; 4 | import org.junit.Test; 5 | 6 | import java.io.File; 7 | import java.util.ArrayList; 8 | 9 | /*import org.jcae.viewer3d.View; 10 | import org.jcae.viewer3d.cad.ViewableCAD; 11 | import org.jcae.viewer3d.cad.occ.OCCProvider;*/ 12 | 13 | /** Test circles, extrude, BRepTools_Quilt */ 14 | public class CircleExtrudeQuilt 15 | { 16 | /** Easy creation of faces */ 17 | private static TopoDS_Face createFace(TopoDS_Edge e1) 18 | { 19 | TopoDS_Wire wirePlate= 20 | (TopoDS_Wire) new BRepBuilderAPI_MakeWire(e1).shape(); 21 | return (TopoDS_Face) new BRepBuilderAPI_MakeFace(wirePlate, true).shape(); 22 | } 23 | 24 | private static TopoDS_Edge getLastEdge(TopoDS_Shape shape) 25 | { 26 | TopExp_Explorer exp=new TopExp_Explorer(shape, TopAbs_ShapeEnum.EDGE); 27 | TopoDS_Edge lastEdge=null; 28 | while(exp.more()) 29 | { 30 | lastEdge=(TopoDS_Edge) exp.current(); 31 | exp.next(); 32 | } 33 | return lastEdge; 34 | } 35 | 36 | private static TopoDS_Edge createCircle(double cx, double cy, double cz, double dx, double dy, double dz, double radius) 37 | { 38 | GP_Circ circleB=new GP_Circ(new double[]{cx, cy, cz, dx, dy, dz}, radius); 39 | return (TopoDS_Edge) new BRepBuilderAPI_MakeEdge(circleB).shape(); 40 | } 41 | 42 | private static TopoDS_Face createFace(TopoDS_Wire wire1, TopoDS_Wire wire2) 43 | { 44 | TopoDS_Face face=(TopoDS_Face) new BRepBuilderAPI_MakeFace(wire1, true).shape(); 45 | return (TopoDS_Face) new BRepBuilderAPI_MakeFace(face, wire2).shape(); 46 | } 47 | 48 | private static TopoDS_Shell[] createShell(TopoDS_Face[] faces) 49 | { 50 | BRepTools_Quilt quil=new BRepTools_Quilt(); 51 | for(int i=0; i "); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src-java-test/org/jcae/opencascade/jni/HoleFilletChamfer.java: -------------------------------------------------------------------------------- 1 | package org.jcae.opencascade.jni; 2 | 3 | import static org.junit.Assert.*; 4 | import org.junit.Test; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.HashSet; 9 | 10 | // Packages for 3D display 11 | /*import java.awt.Container; 12 | import java.awt.GridLayout; 13 | import java.awt.Window; 14 | import java.awt.event.KeyAdapter; 15 | import java.awt.event.KeyEvent; 16 | import javax.media.j3d.Transform3D; 17 | import javax.swing.JFrame; 18 | import javax.swing.WindowConstants; 19 | import javax.vecmath.Matrix4d; 20 | import org.jcae.viewer3d.PositionListener; 21 | import org.jcae.viewer3d.View; 22 | import org.jcae.viewer3d.ViewBehavior; 23 | import org.jcae.viewer3d.cad.ViewableCAD; 24 | import org.jcae.viewer3d.cad.occ.OCCProvider;*/ 25 | 26 | 27 | /** 28 | * A dirty static class to show what are holes, chamfer and fillet 29 | * @author Jerome Robert 30 | */ 31 | public class HoleFilletChamfer 32 | { 33 | /** Return the list of face owning the given edge */ 34 | private static TopoDS_Face[] getFace(TopoDS_Shape shape, TopoDS_Edge edge) 35 | { 36 | ArrayList toReturn=new ArrayList(); 37 | TopExp_Explorer exp=new TopExp_Explorer(shape, TopAbs_ShapeEnum.FACE); 38 | while(exp.more()) 39 | { 40 | TopoDS_Face face=(TopoDS_Face) exp.current(); 41 | HashSet edges = new HashSet(Arrays.asList(getEdges(face))); 42 | if(edges.contains(edge)) 43 | toReturn.add(face); 44 | exp.next(); 45 | } 46 | return (TopoDS_Face[]) toReturn.toArray(new TopoDS_Face[toReturn.size()]); 47 | } 48 | 49 | private static TopoDS_Edge[] getEdges(TopoDS_Shape face) 50 | { 51 | HashSet toReturn=new HashSet(); 52 | TopExp_Explorer exp=new TopExp_Explorer(face, TopAbs_ShapeEnum.EDGE); 53 | while(exp.more()) 54 | { 55 | toReturn.add(exp.current()); 56 | exp.next(); 57 | } 58 | return (TopoDS_Edge[]) toReturn.toArray(new TopoDS_Edge[toReturn.size()]); 59 | } 60 | 61 | private static TopoDS_Shape createCuttedBox() 62 | { 63 | TopoDS_Shape box1 = new BRepPrimAPI_MakeBox( 64 | new double[3], new double[]{4, 3, 2}).shape(); 65 | 66 | TopoDS_Shape box2 = new BRepPrimAPI_MakeBox( 67 | new double[]{-1,-1,-1}, new double[]{3, 2, 1}).shape(); 68 | 69 | return new BRepAlgoAPI_Cut(box1, box2).shape(); 70 | } 71 | 72 | private static TopoDS_Shape createVerticalCylinder(double radius, double x, double y, double height) 73 | { 74 | BRepPrimAPI_MakeCylinder cyl1=new BRepPrimAPI_MakeCylinder( 75 | new double[]{x,y,2,0,0,-1}, radius, height, Math.PI*2); 76 | return cyl1.shape(); 77 | } 78 | 79 | private static TopoDS_Shape makeHole(TopoDS_Shape shape) 80 | { 81 | TopoDS_Shape h1 = createVerticalCylinder(0.05, 0.4, 0.5, 2); 82 | TopoDS_Shape h2 = createVerticalCylinder(0.1, 0.7, 0.5, 0.5); 83 | TopoDS_Shape h3 = createVerticalCylinder(0.07, 3.5, 0.5, 1.9); 84 | TopoDS_Shape toReturn = new BRepAlgoAPI_Cut(shape, h1).shape(); 85 | toReturn = new BRepAlgoAPI_Cut(toReturn, h2).shape(); 86 | toReturn = new BRepAlgoAPI_Cut(toReturn, h3).shape(); 87 | 88 | return toReturn; 89 | } 90 | 91 | @Test public void sample() 92 | { 93 | TopoDS_Shape cuttedBox=createCuttedBox(); 94 | BRepFilletAPI_MakeFillet fillet = new BRepFilletAPI_MakeFillet(cuttedBox); 95 | TopoDS_Edge[] edges = getEdges(cuttedBox); 96 | for(int i=0; i 42 | { 43 | private final static Factory FACTORY=new Factory() 44 | { 45 | public Shape create(TopoDS_Shape shape, 46 | Map map, Shape[] parents) 47 | { 48 | return new Shape(shape, map, parents); 49 | } 50 | 51 | public Shape[] createArray(int length) 52 | { 53 | return new Shape[length]; 54 | } 55 | }; 56 | public Shape(TopoDS_Shape shape) 57 | { 58 | this(shape, new HashMap(), new Shape[0]); 59 | } 60 | protected Shape(TopoDS_Shape shape, Map map, Shape[] parents) 61 | { 62 | super(shape, map, parents); 63 | } 64 | @Override 65 | protected Factory getFactory() { 66 | return FACTORY; 67 | } 68 | 69 | @Override 70 | protected Shape getDerived() { 71 | return this; 72 | } 73 | 74 | public TopoDS_Shape getImpl() { 75 | return impl; 76 | } 77 | } 78 | 79 | private static List createMeshEdge(double[] p1, double[] p2, int n) 80 | { 81 | TopoDS_Vertex[] toReturn = new TopoDS_Vertex[n]; 82 | double[] pp1 = new double[3]; 83 | for(int i = 0; i vertices = new ArrayList(); 102 | for(int i = 0; i toReturn) 179 | toReturn = t; 180 | it.next(); 181 | } 182 | return toReturn; 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /src-java/org/jcae/opencascade/jni/BRepOffsetAPI_Sewing.java: -------------------------------------------------------------------------------- 1 | package org.jcae.opencascade.jni; 2 | 3 | /** 4 | * This class seems be deprecated in Opencascade 6.2 5 | * 6 | * @deprecated use BRepBuilderAPI_Sewing 7 | */ 8 | public class BRepOffsetAPI_Sewing extends BRepBuilderAPI_Sewing { 9 | /** 10 | * @deprecated use BRepBuilderAPI_Sewing 11 | */ 12 | public BRepOffsetAPI_Sewing(double tolerance, boolean option, 13 | boolean cutting, boolean nonmanifold) { 14 | super(tolerance, option, cutting, nonmanifold); 15 | } 16 | 17 | /** 18 | * @deprecated use BRepBuilderAPI_Sewing 19 | */ 20 | public BRepOffsetAPI_Sewing(double tolerance, boolean option, 21 | boolean cutting) { 22 | super(tolerance, option, cutting); 23 | } 24 | 25 | /** 26 | * @deprecated use BRepBuilderAPI_Sewing 27 | */ 28 | public BRepOffsetAPI_Sewing(double tolerance, boolean option) { 29 | super(tolerance, option); 30 | } 31 | 32 | /** 33 | * @deprecated use BRepBuilderAPI_Sewing 34 | */ 35 | public BRepOffsetAPI_Sewing(double tolerance) { 36 | super(tolerance); 37 | } 38 | 39 | /** 40 | * @deprecated use BRepBuilderAPI_Sewing 41 | */ 42 | public BRepOffsetAPI_Sewing() { 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src-java/org/jcae/opencascade/jni/Geom2d_GeometryEnum.java: -------------------------------------------------------------------------------- 1 | package org.jcae.opencascade.jni; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | 5 | public enum Geom2d_GeometryEnum { 6 | 7 | LINE(300, Geom2d_Line.class), 8 | CIRCLE(301, Geom2d_Circle.class), 9 | ELLIPSE(302, Geom2d_Ellipse.class), 10 | HYPERBOLA(303, Geom2d_Hyperbola.class), 11 | PARABOLA(304, Geom2d_Parabola.class), 12 | OFFSET_CURVE(305, Geom2d_OffsetCurve.class), 13 | BEZIER_CURVE(306, Geom2d_BezierCurve.class), 14 | BSPLINE_CURVE(307, Geom2d_BSplineCurve.class), 15 | TRIMMED_CURVE(308, Geom2d_TrimmedCurve.class), 16 | BISEC_ANA(309, Bisector_BisecAna.class), 17 | BISEC_CC(310, Bisector_BisecCC.class), 18 | BISEC_PC(311, Bisector_BisecPC.class); 19 | 20 | private final int swigValue; 21 | private final Class cls; 22 | 23 | private Geom2d_GeometryEnum(int swigValue, Class cls) { 24 | 25 | this.swigValue = swigValue; 26 | this.cls = cls; 27 | 28 | } 29 | 30 | public final int swigValue() { 31 | 32 | return swigValue; 33 | 34 | } 35 | 36 | @SuppressWarnings("unchecked") 37 | public T getDowncastedGeometry(Geom2d_Geometry geometry) { 38 | 39 | return (T) Geom2d_GeometryEnum.genericDowncast(geometry, cls); 40 | 41 | } 42 | 43 | private static T genericDowncast(Geom2d_Geometry geometry, Class cls) { 44 | 45 | T geomObj = null; 46 | 47 | long ptr = Geom2d_Geometry.getCPtr(geometry); 48 | try { 49 | 50 | geomObj = cls.getConstructor(long.class, boolean.class).newInstance(ptr, false); 51 | 52 | } catch (IllegalArgumentException e) { 53 | e.printStackTrace(); 54 | } catch (SecurityException e) { 55 | e.printStackTrace(); 56 | } catch (InstantiationException e) { 57 | e.printStackTrace(); 58 | } catch (IllegalAccessException e) { 59 | e.printStackTrace(); 60 | } catch (InvocationTargetException e) { 61 | e.printStackTrace(); 62 | } catch (NoSuchMethodException e) { 63 | e.printStackTrace(); 64 | } 65 | 66 | return geomObj; 67 | 68 | } 69 | 70 | public static Geom2d_GeometryEnum swigToEnum(int swigValue) { 71 | 72 | Geom2d_GeometryEnum[] swigValues = Geom2d_GeometryEnum.class.getEnumConstants(); 73 | 74 | for (Geom2d_GeometryEnum swigEnum : swigValues) { 75 | if (swigEnum.swigValue == swigValue) { 76 | return swigEnum; 77 | } 78 | } 79 | 80 | throw new IllegalArgumentException("No enum " 81 | + Geom2d_GeometryEnum.class + " with value " + swigValue); 82 | 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src-java/org/jcae/opencascade/jni/Geom_GeometryEnum.java: -------------------------------------------------------------------------------- 1 | package org.jcae.opencascade.jni; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | 5 | public enum Geom_GeometryEnum { 6 | 7 | BEZIER_CURVE(100, Geom_BezierCurve.class), 8 | BSPLINE_CURVE(101, Geom_BSplineCurve.class), 9 | CIRCLE(102, Geom_Circle.class), 10 | ELLIPSE(103, Geom_Ellipse.class), 11 | TRIMMED_CURVE(104, Geom_TrimmedCurve.class), 12 | OFFSET_CURVE(105, Geom_OffsetCurve.class), 13 | HYPERBOLA(106, Geom_Hyperbola.class), 14 | LINE(107, Geom_Line.class), 15 | PARABOLA(108, Geom_Parabola.class), 16 | 17 | BEZIER_SURFACE(200, Geom_BezierSurface.class), 18 | BSPLINE_SURFACE(201, Geom_BSplineSurface.class), 19 | RECTANGULAR_TRIMMED_SURFACE(202, Geom_RectangularTrimmedSurface.class), 20 | SPHERICAL_SURFACE(203, Geom_SphericalSurface.class), 21 | TOROIDAL_SURFACE(204, Geom_ToroidalSurface.class), 22 | OFFSET_SURFACE(205, Geom_OffsetSurface.class), 23 | SURFACE_OF_REVOLUTION(206, Geom_SurfaceOfRevolution.class), 24 | CONICAL_SURFACE(207, Geom_ConicalSurface.class), 25 | CYLINDRICAL_SURFACE(208, Geom_CylindricalSurface.class), 26 | SURFACE_OF_LINEAR_EXTRUSION(209, Geom_SurfaceOfLinearExtrusion.class), 27 | PLANE(210, Geom_Plane.class); 28 | 29 | private final int swigValue; 30 | private final Class cls; 31 | 32 | private Geom_GeometryEnum(int swigValue, Class cls) { 33 | 34 | this.swigValue = swigValue; 35 | this.cls = cls; 36 | 37 | } 38 | 39 | public final int swigValue() { 40 | 41 | return swigValue; 42 | 43 | } 44 | 45 | @SuppressWarnings("unchecked") 46 | public T getDowncastedGeometry(Geom_Geometry geometry) { 47 | 48 | return (T) Geom_GeometryEnum.genericDowncast(geometry, cls); 49 | 50 | } 51 | 52 | private static T genericDowncast(Geom_Geometry geometry, Class cls) { 53 | 54 | T geomObj = null; 55 | 56 | long ptr = Geom_Geometry.getCPtr(geometry); 57 | try { 58 | 59 | geomObj = cls.getConstructor(long.class, boolean.class).newInstance(ptr, false); 60 | 61 | } catch (IllegalArgumentException e) { 62 | e.printStackTrace(); 63 | } catch (SecurityException e) { 64 | e.printStackTrace(); 65 | } catch (InstantiationException e) { 66 | e.printStackTrace(); 67 | } catch (IllegalAccessException e) { 68 | e.printStackTrace(); 69 | } catch (InvocationTargetException e) { 70 | e.printStackTrace(); 71 | } catch (NoSuchMethodException e) { 72 | e.printStackTrace(); 73 | } 74 | 75 | return geomObj; 76 | 77 | } 78 | 79 | public static Geom_GeometryEnum swigToEnum(int swigValue) { 80 | 81 | Geom_GeometryEnum[] swigValues = Geom_GeometryEnum.class.getEnumConstants(); 82 | 83 | for (Geom_GeometryEnum swigEnum : swigValues) { 84 | if (swigEnum.swigValue == swigValue) { 85 | return swigEnum; 86 | } 87 | } 88 | 89 | throw new IllegalArgumentException("No enum " + Geom_GeometryEnum.class 90 | + " with value " + swigValue); 91 | 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/APIHeaderSection_MakeHeader.i: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | %} 4 | 5 | class APIHeaderSection_MakeHeader{ 6 | %rename(setName) SetName; 7 | %rename(setAuthorValue) SetAuthorValue; 8 | %rename(setOrganizationValue) SetOrganizationValue; 9 | %rename(setOriginatingSystem) SetOriginatingSystem; 10 | %rename(setDescriptionValue) SetDescriptionValue; 11 | 12 | public: 13 | APIHeaderSection_MakeHeader(const Handle_StepData_StepModel& model); 14 | void SetName(const Handle_TCollection_HAsciiString& aName); 15 | void SetAuthorValue (const Standard_Integer num,const Handle_TCollection_HAsciiString& aAuthor); 16 | void SetOrganizationValue (const Standard_Integer num,const Handle_TCollection_HAsciiString& aOrganization); 17 | void SetOriginatingSystem(const Handle_TCollection_HAsciiString& aOriginatingSystem); 18 | void SetDescriptionValue(const Standard_Integer num,const Handle_TCollection_HAsciiString& description); 19 | }; -------------------------------------------------------------------------------- /src/BRep.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{ 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | %} 28 | 29 | %rename(Geom2d_Curve) Handle_Geom2d_Curve; 30 | %rename(Geom_Curve) Handle_Geom_Curve; 31 | %rename(Geom_Surface) Handle_Geom_Surface; 32 | 33 | %typemap(javacode) BRep_Tool 34 | %{ 35 | public static double[] range(TopoDS_Edge edge) 36 | { 37 | double[] toReturn=new double[2]; 38 | range(edge, toReturn); 39 | return toReturn; 40 | } 41 | 42 | public static Geom2d_Curve curveOnSurface(TopoDS_Edge e, TopoDS_Face f, double[] range) 43 | { 44 | double[] d2=new double[1]; 45 | Geom2d_Curve toReturn=curveOnSurface(e, f, range, d2); 46 | range[1]=d2[0]; 47 | return toReturn; 48 | } 49 | 50 | public static Geom_Curve curve(TopoDS_Edge e, double[] range) 51 | { 52 | double[] d2=new double[1]; 53 | // this calls java BRep_Tool.curve defined below 54 | Geom_Curve toReturn=curve(e, range, d2); 55 | range[1]=d2[0]; 56 | return toReturn; 57 | } 58 | %} 59 | 60 | %catches(Standard_NoSuchObject) BRep_Tool::Parameters; 61 | 62 | class BRep_Tool 63 | { 64 | %rename(pnt) Pnt; 65 | %rename(parameters) Parameters; 66 | %rename(parameter) Parameter; 67 | %rename(degenerated) Degenerated; 68 | %rename(hasContinuity) HasContinuity; 69 | %rename(continuity) Continuity; 70 | %rename(tolerance) Tolerance; 71 | %rename(curve) Curve; 72 | %rename(surface) Surface; 73 | %rename(curveOnSurface) CurveOnSurface; 74 | public: 75 | static const gp_Pnt Pnt(const TopoDS_Vertex& V) ; 76 | static gp_Pnt2d Parameters(const TopoDS_Vertex& V,const TopoDS_Face& F) ; 77 | static Standard_Real Parameter(const TopoDS_Vertex& V,const TopoDS_Edge& E) ; 78 | static Standard_Boolean Degenerated(const TopoDS_Edge& E) ; 79 | static Standard_Boolean SameParameter(const TopoDS_Edge& E) ; 80 | static Standard_Boolean SameRange(const TopoDS_Edge& E) ; 81 | static Standard_Boolean HasContinuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2) ; 82 | static GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2) ; 83 | static Standard_Real Tolerance(const TopoDS_Face& F) ; 84 | static Standard_Real Tolerance(const TopoDS_Edge& E) ; 85 | static Standard_Real Tolerance(const TopoDS_Vertex& V) ; 86 | static Standard_Boolean IsClosed(const TopoDS_Shape &S) ; 87 | 88 | /* static Handle_Geom_Curve Curve(const TopoDS_Edge& E, Standard_Real& First,Standard_Real& Last) ; 89 | static Handle_Geom_Surface Surface(const TopoDS_Face& F) ; 90 | static Handle_Geom2d_Curve CurveOnSurface(const TopoDS_Edge& E, const TopoDS_Face& F,Standard_Real& First,Standard_Real& Last) ; 91 | */ 92 | }; 93 | 94 | // Publish methods which return pointer instead of Handle. We do not need 95 | // Handle because Java do the memory managment for us. 96 | %extend BRep_Tool 97 | { 98 | static Poly_Triangulation * triangulation(const TopoDS_Face& F,TopLoc_Location& L) 99 | { 100 | Handle_Poly_Triangulation hgc=BRep_Tool::Triangulation(F,L); 101 | if(hgc.IsNull()) 102 | return NULL; 103 | else 104 | return (Poly_Triangulation*)(Standard_Transient*)hgc; 105 | } 106 | 107 | static void range(const TopoDS_Edge& E, double range[2]) 108 | { 109 | BRep_Tool::Range(E, range[0], range[1]); 110 | } 111 | 112 | // new Handle is a little memory leak as this handle is never deleted 113 | static Handle_Geom_Curve * curve(const TopoDS_Edge& E, 114 | Standard_Real& First,Standard_Real& Last) 115 | { 116 | Handle_Geom_Curve * hgc=new Handle_Geom_Curve(BRep_Tool::Curve(E, First, Last)); 117 | if(hgc->IsNull()) 118 | return NULL; 119 | else 120 | return hgc; 121 | } 122 | 123 | static Handle_Geom_Surface * surface(const TopoDS_Face& F) 124 | { 125 | Handle_Geom_Surface * hgc=new Handle_Geom_Surface(BRep_Tool::Surface(F)); 126 | if(hgc->IsNull()) 127 | return NULL; 128 | else 129 | return hgc; 130 | } 131 | 132 | static Handle_Geom2d_Curve * curveOnSurface(const TopoDS_Edge& E, 133 | const TopoDS_Face& F,Standard_Real& First,Standard_Real& Last) 134 | { 135 | Handle_Geom2d_Curve * hgc=new Handle_Geom2d_Curve(BRep_Tool::CurveOnSurface(E, F, First, Last)); 136 | if(hgc->IsNull()) 137 | return NULL; 138 | else 139 | return hgc; 140 | } 141 | }; 142 | 143 | class BRep_Builder: public TopoDS_Builder 144 | { 145 | %rename(updateVertex) UpdateVertex; 146 | public: 147 | BRep_Builder(); 148 | void MakeFace(TopoDS_Face& F) const; 149 | void MakeFace(TopoDS_Face& F, const Handle_Geom_Surface& S, const Standard_Real tol) const; 150 | void MakeFace(TopoDS_Face& F, const Handle_Geom_Surface& S, const TopLoc_Location& L, const Standard_Real tol) const; 151 | 152 | void MakeEdge(TopoDS_Edge& E) const; 153 | void MakeEdge(TopoDS_Edge& E, const Handle_Geom_Curve& C, const Standard_Real tol) const; 154 | void MakeEdge(TopoDS_Edge& E, const Handle_Geom_Curve& C, const TopLoc_Location& L, const Standard_Real tol) const; 155 | void UpdateEdge(const TopoDS_Edge& edge, const Handle_Geom_Curve& C, const Standard_Real tolerance) const; 156 | void UpdateEdge(const TopoDS_Edge& edge, const Handle_Geom2d_Curve& C, const TopoDS_Face& F, const Standard_Real tolerance) const; 157 | void UpdateEdge(const TopoDS_Edge& edge, const Handle_Geom2d_Curve& C1, const Handle_Geom2d_Curve& C2, const TopoDS_Face& F, const Standard_Real tolerance) const; 158 | 159 | void MakeVertex(TopoDS_Vertex& V) const; 160 | void MakeVertex(TopoDS_Vertex& V, const gp_Pnt& P, const Standard_Real tol) const; 161 | void UpdateVertex(const TopoDS_Vertex& vertex, const Standard_Real u, const Standard_Real v, const TopoDS_Face& face, const Standard_Real tolerance) const; 162 | void UpdateVertex(const TopoDS_Vertex& vertex, const Standard_Real tolerance) const; 163 | 164 | void Degenerated(const TopoDS_Edge& E, const Standard_Boolean D) const ; 165 | }; 166 | 167 | -------------------------------------------------------------------------------- /src/BRepAlgoAPI.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{#include %} 22 | %{#include %} 23 | %{#include %} 24 | %{#include %} 25 | %{#include %} 26 | 27 | class BRepAlgoAPI_BooleanOperation: public BRepBuilderAPI_MakeShape 28 | { 29 | %rename(modified) Modified; 30 | %rename(isDeleted) IsDeleted; 31 | %rename(generated) Generated; 32 | %rename(hasModified) HasModified; 33 | %rename(hasGenerated) HasGenerated; 34 | %rename(hasDeleted) HasDeleted; 35 | BRepAlgoAPI_BooleanOperation()=0; 36 | public: 37 | virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& aS) ; 38 | virtual Standard_Boolean IsDeleted(const TopoDS_Shape& aS) ; 39 | virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& S) ; 40 | virtual Standard_Boolean HasModified() const; 41 | virtual Standard_Boolean HasGenerated() const; 42 | virtual Standard_Boolean HasDeleted() const; 43 | }; 44 | 45 | class BRepAlgoAPI_Fuse: public BRepAlgoAPI_BooleanOperation 46 | { 47 | public: 48 | BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,const TopoDS_Shape& S2); 49 | }; 50 | 51 | class BRepAlgoAPI_Common: public BRepAlgoAPI_BooleanOperation 52 | { 53 | public: 54 | BRepAlgoAPI_Common(const TopoDS_Shape& S1,const TopoDS_Shape& S2); 55 | }; 56 | 57 | class BRepAlgoAPI_Cut: public BRepAlgoAPI_BooleanOperation 58 | { 59 | public: 60 | BRepAlgoAPI_Cut(const TopoDS_Shape& S1,const TopoDS_Shape& S2); 61 | }; 62 | 63 | class BRepAlgoAPI_Section: public BRepAlgoAPI_BooleanOperation 64 | { 65 | public: 66 | BRepAlgoAPI_Section(const TopoDS_Shape& S1,const TopoDS_Shape& S2); 67 | }; 68 | 69 | -------------------------------------------------------------------------------- /src/BRepBuilderAPI.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{ 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #if OCC_VERSION_MAJOR >= 6 34 | #include 35 | #else 36 | #include 37 | #define BRepBuilderAPI_Sewing BRepAlgo_Sewing 38 | #endif 39 | %} 40 | %include "enumtypesafe.swg" 41 | enum BRepBuilderAPI_EdgeError {BRepBuilderAPI_EdgeDone, BRepBuilderAPI_PointProjectionFailed, BRepBuilderAPI_ParameterOutOfRange, BRepBuilderAPI_DifferentPointsOnClosedCurve, 42 | BRepBuilderAPI_PointWithInfiniteParameter, BRepBuilderAPI_DifferentsPointAndParameter, BRepBuilderAPI_LineThroughIdenticPoints}; 43 | enum BRepBuilderAPI_FaceError {BRepBuilderAPI_FaceDone, BRepBuilderAPI_NoFace, BRepBuilderAPI_NotPlanar, BRepBuilderAPI_CurveProjectionFailed, BRepBuilderAPI_ParametersOutOfRange}; 44 | enum BRepBuilderAPI_WireError {BRepBuilderAPI_WireDone, BRepBuilderAPI_EmptyWire, BRepBuilderAPI_DisconnectedWire, BRepBuilderAPI_NonManifoldWire}; 45 | enum BRepBuilderAPI_ShellError {BRepBuilderAPI_ShellDone, BRepBuilderAPI_EmptyShell, BRepBuilderAPI_DisconnectedShell, BRepBuilderAPI_ShellParametersOutOfRange}; 46 | 47 | class BRepBuilderAPI_Command 48 | { 49 | %rename(isDone) IsDone; 50 | BRepBuilderAPI_Command()=0; 51 | public: 52 | virtual Standard_Boolean IsDone() const; 53 | }; 54 | 55 | class BRepBuilderAPI_MakeShape: public BRepBuilderAPI_Command 56 | { 57 | //Hide the constructor to make this class abstract 58 | BRepBuilderAPI_MakeShape()=0; 59 | public: 60 | %rename(build) Build; 61 | %rename(shape) Shape; 62 | virtual void Build(); 63 | const TopoDS_Shape& Shape() const; 64 | }; 65 | 66 | class BRepBuilderAPI_ModifyShape: public BRepBuilderAPI_MakeShape 67 | { 68 | %rename(modifiedShape) ModifiedShape; 69 | BRepBuilderAPI_ModifyShape()=0; 70 | public: 71 | virtual const TopoDS_Shape& ModifiedShape(const TopoDS_Shape& S) const; 72 | }; 73 | 74 | class BRepBuilderAPI_Transform : public BRepBuilderAPI_ModifyShape 75 | { 76 | %rename(perform) Perform; 77 | public: 78 | BRepBuilderAPI_Transform(const gp_Trsf& T); 79 | BRepBuilderAPI_Transform(const TopoDS_Shape& S, const gp_Trsf& T, 80 | const Standard_Boolean Copy = Standard_False); 81 | void Perform(const TopoDS_Shape& S, 82 | const Standard_Boolean Copy = Standard_False) ; 83 | }; 84 | 85 | class BRepBuilderAPI_MakeVertex: public BRepBuilderAPI_MakeShape 86 | { 87 | %rename(vertex) Vertex; 88 | public: 89 | BRepBuilderAPI_MakeVertex(const gp_Pnt& P); 90 | //const TopoDS_Vertex& Vertex() const; 91 | }; 92 | 93 | class BRepBuilderAPI_MakeWire : public BRepBuilderAPI_MakeShape 94 | { 95 | %rename(wire) Wire; 96 | %rename(add) Add; 97 | %rename(isDone) IsDone; 98 | public: 99 | BRepBuilderAPI_MakeWire(); 100 | BRepBuilderAPI_MakeWire(const TopoDS_Edge& E); 101 | BRepBuilderAPI_MakeWire(const TopoDS_Edge& E1,const TopoDS_Edge& E2); 102 | BRepBuilderAPI_MakeWire(const TopoDS_Edge& E1,const TopoDS_Edge& E2, 103 | const TopoDS_Edge& E3); 104 | BRepBuilderAPI_MakeWire(const TopoDS_Edge& E1,const TopoDS_Edge& E2, 105 | const TopoDS_Edge& E3,const TopoDS_Edge& E4); 106 | BRepBuilderAPI_MakeWire(const TopoDS_Wire& W); 107 | BRepBuilderAPI_MakeWire(const TopoDS_Wire& W,const TopoDS_Edge& E); 108 | void Add(const TopoDS_Edge& E) ; 109 | void Add(const TopoDS_Wire& W) ; 110 | void Add(const TopTools_ListOfShape & shapes); 111 | Standard_Boolean IsDone() const; 112 | BRepBuilderAPI_WireError Error() const; 113 | //const TopoDS_Wire& Wire() const; 114 | }; 115 | 116 | class BRepBuilderAPI_MakeShell : public BRepBuilderAPI_MakeShape 117 | { 118 | %rename(shell) Shell; 119 | %rename(add) Add; 120 | %rename(isDone) IsDone; 121 | public: 122 | BRepBuilderAPI_MakeShell(); 123 | Standard_Boolean IsDone() const; 124 | BRepBuilderAPI_ShellError Error() const; 125 | //const TopoDS_Shell& Shell() const; 126 | }; 127 | 128 | class BRepBuilderAPI_MakeEdge : public BRepBuilderAPI_MakeShape 129 | { 130 | %rename(edge) Edge; 131 | %rename(isDone) IsDone; 132 | public: 133 | BRepBuilderAPI_MakeEdge(); 134 | BRepBuilderAPI_MakeEdge(const Handle_Geom_Curve& L); 135 | BRepBuilderAPI_MakeEdge(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2); 136 | BRepBuilderAPI_MakeEdge(const gp_Pnt& P1,const gp_Pnt& P2); 137 | BRepBuilderAPI_MakeEdge(const gp_Circ& L); 138 | BRepBuilderAPI_MakeEdge(const gp_Circ& L,const Standard_Real p1,const Standard_Real p2); 139 | BRepBuilderAPI_MakeEdge(const gp_Circ& L,const gp_Pnt& P1,const gp_Pnt& P2); 140 | BRepBuilderAPI_MakeEdge(const gp_Circ& L,const TopoDS_Vertex& V1,const TopoDS_Vertex& V2); 141 | BRepBuilderAPI_MakeEdge(const gp_Parab& L); 142 | BRepBuilderAPI_MakeEdge(const gp_Parab& L,const Standard_Real p1,const Standard_Real p2); 143 | BRepBuilderAPI_MakeEdge(const gp_Parab& L,const gp_Pnt& P1,const gp_Pnt& P2); 144 | BRepBuilderAPI_MakeEdge(const gp_Parab& L,const TopoDS_Vertex& V1,const TopoDS_Vertex& V2); 145 | BRepBuilderAPI_MakeEdge(const Handle_Geom_Curve& L, const TopoDS_Vertex& V1,const TopoDS_Vertex& V2); 146 | BRepBuilderAPI_MakeEdge(const Handle_Geom_Curve& L, const TopoDS_Vertex& V1,const TopoDS_Vertex& V2,const Standard_Real p1,const Standard_Real p2); 147 | BRepBuilderAPI_MakeEdge(const Handle_Geom_Curve& L, const Standard_Real p1,const Standard_Real p2); 148 | // 2d curves 149 | BRepBuilderAPI_MakeEdge(const Handle_Geom2d_Curve& L, const Handle_Geom_Surface& S, const Standard_Real p1,const Standard_Real p2); 150 | Standard_Boolean IsDone() const; 151 | BRepBuilderAPI_EdgeError Error() const; 152 | //const TopoDS_Edge& Edge() const; 153 | }; 154 | 155 | class BRepBuilderAPI_MakeFace : public BRepBuilderAPI_MakeShape 156 | { 157 | %rename(face) Face; 158 | public: 159 | BRepBuilderAPI_MakeFace(const TopoDS_Wire& W, 160 | const Standard_Boolean OnlyPlane = Standard_False); 161 | BRepBuilderAPI_MakeFace(const TopoDS_Face& F,const TopoDS_Wire& W); 162 | BRepBuilderAPI_MakeFace(const Handle_Geom_Surface& S,const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True ); 163 | BRepBuilderAPI_MakeFace(const Handle_Geom_Surface& S, const Standard_Real Umin, const Standard_Real Umax, 164 | const Standard_Real Vmin, const Standard_Real Vmax, const Standard_Real tolDegen); 165 | Standard_Boolean IsDone() const; 166 | BRepBuilderAPI_FaceError Error() const; 167 | //const TopoDS_Face& Face() const; 168 | }; 169 | 170 | class BRepBuilderAPI_MakeSolid: public BRepBuilderAPI_MakeShape 171 | { 172 | %rename(add) Add; 173 | %rename(isDone) IsDone; 174 | %rename(isDeleted) IsDeleted; 175 | public: 176 | BRepBuilderAPI_MakeSolid(); 177 | BRepBuilderAPI_MakeSolid(const TopoDS_CompSolid& S); 178 | BRepBuilderAPI_MakeSolid(const TopoDS_Shell& S); 179 | BRepBuilderAPI_MakeSolid(const TopoDS_Shell& S1,const TopoDS_Shell& S2); 180 | BRepBuilderAPI_MakeSolid(const TopoDS_Shell& S1,const TopoDS_Shell& S2,const TopoDS_Shell& S3); 181 | BRepBuilderAPI_MakeSolid(const TopoDS_Solid& So); 182 | BRepBuilderAPI_MakeSolid(const TopoDS_Solid& So,const TopoDS_Shell& S); 183 | void Add(const TopoDS_Shell& S) ; 184 | Standard_Boolean IsDone() const; 185 | Standard_Boolean IsDeleted(const TopoDS_Shape& S) ; 186 | }; 187 | 188 | class BRepBuilderAPI_Sewing 189 | { 190 | public: 191 | 192 | %rename(init) Init; 193 | %rename(add) Add; 194 | %rename(perform) Perform; 195 | %rename(sewedShape) SewedShape; 196 | 197 | %rename(load) Load; 198 | %rename(nbFreeEdges) NbFreeEdges; 199 | %rename(freeEdge) FreeEdge; 200 | %rename(nbMultipleEdges) NbMultipleEdges; 201 | %rename(multipleEdge) MultipleEdge; 202 | %rename(nbDegeneratedShapes) NbDegeneratedShapes; 203 | %rename(degeneratedShape) DegeneratedShape; 204 | %rename(nbDeletedFaces) NbDeletedFaces; 205 | %rename(deletedFace) DeletedFace; 206 | %rename(isDegenerated) IsDegenerated; 207 | %rename(isModified) IsModified; 208 | %rename(modified) Modified; 209 | %rename(dump) Dump; 210 | 211 | %rename(isModifiedSubShape) IsModifiedSubShape; 212 | %rename(modifiedSubShape) ModifiedSubShape; 213 | 214 | BRepBuilderAPI_Sewing(const Standard_Real tolerance = 1.0e-06, 215 | const Standard_Boolean option = Standard_True, 216 | const Standard_Boolean cutting = Standard_True, 217 | const Standard_Boolean nonmanifold = Standard_False); 218 | void Init(const Standard_Real tolerance, 219 | const Standard_Boolean option = Standard_True, 220 | const Standard_Boolean cutting = Standard_True, 221 | const Standard_Boolean nonmanifold = Standard_False) ; 222 | void Load(const TopoDS_Shape& shape) ; 223 | void Add(const TopoDS_Shape& shape) ; 224 | void Perform() ; 225 | const TopoDS_Shape& SewedShape() const; 226 | Standard_Integer NbFreeEdges() const; 227 | const TopoDS_Edge& FreeEdge(const Standard_Integer index) const; 228 | Standard_Integer NbMultipleEdges() const; 229 | const TopoDS_Edge& MultipleEdge(const Standard_Integer index) const; 230 | Standard_Integer NbDegeneratedShapes() const; 231 | const TopoDS_Shape& DegeneratedShape(const Standard_Integer index) const; 232 | Standard_Integer NbDeletedFaces() const; 233 | const TopoDS_Face& DeletedFace(const Standard_Integer index) const; 234 | Standard_Boolean IsDegenerated(const TopoDS_Shape& shape) const; 235 | Standard_Boolean IsModified(const TopoDS_Shape& shape) const; 236 | const TopoDS_Shape& Modified(const TopoDS_Shape& shape) const; 237 | void Dump() const; 238 | 239 | Standard_Boolean IsModifiedSubShape(const TopoDS_Shape& shape) const; 240 | TopoDS_Shape ModifiedSubShape(const TopoDS_Shape& shape) const; 241 | }; 242 | 243 | class BRepBuilderAPI_NurbsConvert : public BRepBuilderAPI_ModifyShape 244 | { 245 | %rename(perform) Perform; 246 | public: 247 | BRepBuilderAPI_NurbsConvert(); 248 | BRepBuilderAPI_NurbsConvert(const TopoDS_Shape& S, 249 | const Standard_Boolean Copy = Standard_False); 250 | void Perform(const TopoDS_Shape& S, 251 | const Standard_Boolean Copy = Standard_False) ; 252 | }; 253 | 254 | -------------------------------------------------------------------------------- /src/BRepCheck.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2007, by EADS France 19 | */ 20 | 21 | %{#include %} 22 | 23 | class BRepCheck_Analyzer 24 | { 25 | public: 26 | 27 | %rename(init) Init; 28 | %rename(isValid) IsValid; 29 | 30 | BRepCheck_Analyzer(const TopoDS_Shape& S,const Standard_Boolean GeomControls = Standard_True); 31 | void Init(const TopoDS_Shape& S,const Standard_Boolean GeomControls = Standard_True) ; 32 | Standard_Boolean IsValid() const; 33 | }; 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/BRepFilletAPI.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2007, by EADS France 19 | */ 20 | %{#include %} 21 | %{#include %} 22 | 23 | class BRepFilletAPI_LocalOperation: public BRepBuilderAPI_MakeShape 24 | { 25 | }; 26 | 27 | %rename(Rational) ChFi3d_Rational; 28 | %rename(QuasiAngular) ChFi3d_QuasiAngular; 29 | %rename(Polynomial) ChFi3d_Polynomial; 30 | 31 | enum ChFi3d_FilletShape { 32 | ChFi3d_Rational, 33 | ChFi3d_QuasiAngular, 34 | ChFi3d_Polynomial 35 | }; 36 | 37 | class BRepFilletAPI_MakeFillet: public BRepFilletAPI_LocalOperation 38 | { 39 | %rename(add) Add; 40 | public: 41 | BRepFilletAPI_MakeFillet(const TopoDS_Shape& shape, const ChFi3d_FilletShape type = ChFi3d_Rational); 42 | void Add(const Standard_Real radius, const TopoDS_Edge& edge) ; 43 | }; 44 | 45 | class BRepFilletAPI_MakeChamfer: public BRepFilletAPI_LocalOperation 46 | { 47 | %rename(add) Add; 48 | public: 49 | BRepFilletAPI_MakeChamfer(const TopoDS_Shape& shape); 50 | void Add(const Standard_Real distance, const TopoDS_Edge& edge, const TopoDS_Face& face); 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /src/BRepLib.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{ 22 | #include 23 | %} 24 | 25 | class BRepLib 26 | { 27 | public: 28 | %rename(encodeRegularity) EncodeRegularity; 29 | static void EncodeRegularity(const TopoDS_Shape& S,const Standard_Real TolAng = 1.0e-10) ; 30 | }; 31 | 32 | -------------------------------------------------------------------------------- /src/BRepOffsetAPI.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2011, by EADS France 19 | */ 20 | 21 | %{ 22 | #include 23 | %} 24 | 25 | class BRepOffsetAPI_NormalProjection: public BRepBuilderAPI_MakeShape 26 | { 27 | public: 28 | %rename(init) Init; 29 | %rename(add) Add; 30 | %rename(setParams) SetParams; 31 | %rename(setMaxDistance) SetMaxDistance; 32 | %rename(setLimit) SetLimit; 33 | %rename(compute3d) Compute3d; 34 | %rename(build) Build; 35 | %rename(isDone) IsDone; 36 | %rename(projection) Projection; 37 | %rename(couple) Couple; 38 | %rename(generated) Generated; 39 | %rename(ancestor) Ancestor; 40 | %rename(buildWire) BuildWire; 41 | BRepOffsetAPI_NormalProjection(); 42 | BRepOffsetAPI_NormalProjection(const TopoDS_Shape& S); 43 | void Init(const TopoDS_Shape& S) ; 44 | void Add(const TopoDS_Shape& ToProj) ; 45 | void SetParams(const Standard_Real Tol3D,const Standard_Real Tol2D,const GeomAbs_Shape InternalContinuity,const Standard_Integer MaxDegree,const Standard_Integer MaxSeg) ; 46 | void SetMaxDistance(const Standard_Real MaxDist) ; 47 | void SetLimit(const Standard_Boolean FaceBoundaries = Standard_True) ; 48 | void Compute3d(const Standard_Boolean With3d = Standard_True) ; 49 | virtual void Build() ; 50 | Standard_Boolean IsDone() const; 51 | const TopoDS_Shape& Projection() const; 52 | const TopoDS_Shape& Couple(const TopoDS_Edge& E) const; 53 | virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& S) ; 54 | const TopoDS_Shape& Ancestor(const TopoDS_Edge& E) const; 55 | Standard_Boolean BuildWire(TopTools_ListOfShape& Liste) const; 56 | }; 57 | -------------------------------------------------------------------------------- /src/BRepPrimAPI.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{ 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | %} 32 | 33 | class BRepPrimAPI_MakeBox : public BRepBuilderAPI_MakeShape 34 | { 35 | public: 36 | BRepPrimAPI_MakeBox(const gp_Pnt& P1,const gp_Pnt& P2); 37 | }; 38 | 39 | class BRepPrimAPI_MakeCone : public BRepBuilderAPI_MakeShape 40 | { 41 | public: 42 | BRepPrimAPI_MakeCone(const gp_Ax2& axes, const Standard_Real baseRadius, 43 | const Standard_Real topRadius,const Standard_Real height, const Standard_Real angle); 44 | }; 45 | 46 | 47 | class BRepPrimAPI_MakeCylinder : public BRepBuilderAPI_MakeShape 48 | { 49 | public: 50 | %javamethodmodifiers BRepPrimAPI_MakeCylinder(const gp_Ax2& axes,const Standard_Real radius, 51 | const Standard_Real height,const Standard_Real angle) " 52 | /** 53 | * @param axes is {X, Y, Z, directionX, directionY, directionZ} 54 | */ 55 | public"; 56 | BRepPrimAPI_MakeCylinder(const gp_Ax2& axes,const Standard_Real radius, 57 | const Standard_Real height,const Standard_Real angle); 58 | }; 59 | 60 | class BRepPrimAPI_MakeTorus : public BRepBuilderAPI_MakeShape 61 | { 62 | public: 63 | BRepPrimAPI_MakeTorus(const gp_Ax2& Axes,const Standard_Real R1, 64 | const Standard_Real R2); 65 | BRepPrimAPI_MakeTorus(const gp_Ax2& Axes, const Standard_Real R1, 66 | const Standard_Real R2, const Standard_Real angle1, 67 | const Standard_Real angle2, const Standard_Real angle); 68 | }; 69 | 70 | class BRepPrimAPI_MakeSphere : public BRepBuilderAPI_MakeShape 71 | { 72 | public: 73 | BRepPrimAPI_MakeSphere(const gp_Pnt& center,const Standard_Real radius); 74 | BRepPrimAPI_MakeSphere(const gp_Ax2& axis,const Standard_Real R,const Standard_Real angle1,const Standard_Real angle2,const Standard_Real angle3); 75 | }; 76 | 77 | class BRepPrimAPI_MakeSweep : public BRepBuilderAPI_MakeShape 78 | { 79 | }; 80 | 81 | class BRepPrimAPI_MakePrism : public BRepPrimAPI_MakeSweep 82 | { 83 | public: 84 | BRepPrimAPI_MakePrism(const TopoDS_Shape& baseShape, const gp_Vec& extrudeDirection, const 85 | Standard_Boolean Copy = Standard_False, 86 | const Standard_Boolean Canonize = Standard_True); 87 | 88 | // gp_Vec and gp_Dir are both translated to double[] so this contructor 89 | // will conflict with the previous one 90 | // TODO: Change the signature to avoir conflict (easy but I have no time for now) 91 | // BRepPrimAPI_MakePrism(const TopoDS_Shape& S,const gp_Dir& D,const 92 | // Standard_Boolean Inf = Standard_True,const Standard_Boolean Copy = 93 | // Standard_False,const Standard_Boolean Canonize = Standard_True); 94 | }; 95 | 96 | class BRepPrimAPI_MakeRevol : public BRepPrimAPI_MakeSweep { 97 | public: 98 | BRepPrimAPI_MakeRevol(const TopoDS_Shape& shape, const gp_Ax1& axis, const Standard_Real angle, const Standard_Boolean copy = Standard_False); 99 | BRepPrimAPI_MakeRevol(const TopoDS_Shape& shape, const gp_Ax1& axis, const Standard_Boolean copy = Standard_False); 100 | }; 101 | 102 | class BRepOffsetAPI_MakePipe : public BRepPrimAPI_MakeSweep { 103 | public: 104 | BRepOffsetAPI_MakePipe(const TopoDS_Wire& Spine,const TopoDS_Shape& Profile); 105 | }; 106 | -------------------------------------------------------------------------------- /src/BRepTools.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{ 22 | #include 23 | #include 24 | %} 25 | 26 | // define another read method that match the one of libOccJava (the one below don't). 27 | %typemap(javacode) BRepTools 28 | %{ 29 | /** 30 | * Read a shape from a file. 31 | * This is an helper method. It do not exists in Opencascade. 32 | * @param file the file to read 33 | * @param builder the builder which will be used to create the shape (i.e. new BRep_Builder()). 34 | */ 35 | public static TopoDS_Shape read(String file, BRep_Builder builder) 36 | { 37 | TopoDS_Shape toReturn=new TopoDS_Shape(); 38 | if(read(toReturn, file, builder)) 39 | return TopoDS_Shape.downcast(toReturn); 40 | else 41 | return null; 42 | } 43 | %} 44 | 45 | %typemap(javaimports) BRepTools " 46 | /** Provides various utilities for BRep. */" 47 | 48 | %typemap(javadestruct, methodname="delete", methodmodifiers="private synchronized") BRepTools {}; 49 | 50 | class BRepTools 51 | { 52 | %javamethodmodifiers Read(TopoDS_Shape& ,const Standard_CString, const BRep_Builder&) " 53 | /** 54 | * Reads a shape from a file. 55 | * @param shape an empty shape created with new TopoDS_Shape() 56 | * @param builder used to build the shape (i.e. new BRep_Builder()). 57 | * @return false on IO or file format errors. 58 | */ 59 | public"; 60 | 61 | //Hide the constructor to make this class entirely static. 62 | BRepTools()=0; 63 | public: 64 | 65 | %rename(read) Read; 66 | static Standard_Boolean Read(TopoDS_Shape& shape, 67 | const Standard_CString file, const BRep_Builder& builder) ; 68 | 69 | %javamethodmodifiers Write(const TopoDS_Shape&, const Standard_CString)" 70 | /** 71 | * Write a shape to a file. 72 | * @param shape the shape to write 73 | * @param file the file where to write the shape 74 | * @return false on IO error. 75 | */ 76 | public"; 77 | 78 | %rename(write) Write; 79 | static Standard_Boolean Write(const TopoDS_Shape& shape, 80 | const Standard_CString file); 81 | 82 | static void Write(const TopoDS_Shape& Sh,Standard_OStream& S) ; 83 | %rename(clean) Clean; 84 | static void Clean(const TopoDS_Shape& S) ; 85 | 86 | %rename(getOuterWire) OuterWire; 87 | static TopoDS_Wire OuterWire(const TopoDS_Face& F) ; 88 | }; 89 | 90 | %extend BRepTools 91 | { 92 | //in the original version of this method opencascade suppose that the format of the stream is 93 | //correct and don't do any verification. It cause segfault when the stream is wrong. 94 | static Standard_Boolean read(TopoDS_Shape& shape, Standard_IStream& input, const BRep_Builder& builder) 95 | { 96 | BRepTools_ShapeSet SS(builder); 97 | SS.Read(input); 98 | if(!SS.NbShapes()) return Standard_False; 99 | SS.Read(shape,input); 100 | return Standard_True; 101 | } 102 | } 103 | 104 | 105 | /** 106 | * BRepTools_WireExplorer 107 | */ 108 | %{#include %} 109 | class BRepTools_WireExplorer 110 | { 111 | %rename(init) Init; 112 | %rename(more) More; 113 | %rename(next) Next; 114 | %rename(current) Current; 115 | %rename(orientation) Orientation; 116 | %rename(currentVertex) CurrentVertex; 117 | %rename(clear) Clear; 118 | public: 119 | BRepTools_WireExplorer(); 120 | BRepTools_WireExplorer(const TopoDS_Wire& W); 121 | BRepTools_WireExplorer(const TopoDS_Wire& W,const TopoDS_Face& F); 122 | void Init(const TopoDS_Wire& W) ; 123 | void Init(const TopoDS_Wire& W,const TopoDS_Face& F) ; 124 | Standard_Boolean More() const; 125 | void Next() ; 126 | const TopoDS_Edge& Current() const; 127 | TopAbs_Orientation Orientation() const; 128 | const TopoDS_Vertex& CurrentVertex() const; 129 | void Clear() ; 130 | }; 131 | 132 | %{#include %} 133 | class BRepTools_Quilt 134 | { 135 | %rename(bind) Bind; 136 | %rename(add) Add; 137 | %rename(isCopied) IsCopied; 138 | %rename(copy) Copy; 139 | %rename(shells) Shells; 140 | public: 141 | BRepTools_Quilt(); 142 | void Bind(const TopoDS_Edge& Eold,const TopoDS_Edge& Enew) ; 143 | void Bind(const TopoDS_Vertex& Vold,const TopoDS_Vertex& Vnew) ; 144 | void Add(const TopoDS_Shape& S) ; 145 | Standard_Boolean IsCopied(const TopoDS_Shape& S) const; 146 | const TopoDS_Shape& Copy(const TopoDS_Shape& S) const; 147 | TopoDS_Shape Shells() const; 148 | }; 149 | -------------------------------------------------------------------------------- /src/GC.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * 15 | * @author Jens Schmidt 16 | * 17 | */ 18 | 19 | %{#include %} 20 | 21 | class GC_MakeArcOfCircle { 22 | public: 23 | GC_MakeArcOfCircle(const gp_Pnt& P1,const gp_Pnt& P2,const gp_Pnt& P3); 24 | GC_MakeArcOfCircle(const gp_Circ& Circ,const gp_Pnt& P1,const gp_Pnt& P2,const Standard_Boolean Sense); 25 | const Handle_Geom_TrimmedCurve& Value() const; 26 | }; -------------------------------------------------------------------------------- /src/GeomAPI.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * 15 | * @author Jens Schmidt 16 | * 17 | */ 18 | 19 | %{#include %} 20 | %{#include %} 21 | 22 | class GeomAPI_PointsToBSpline { 23 | public: 24 | GeomAPI_PointsToBSpline(); 25 | GeomAPI_PointsToBSpline(const TColgp_Array1OfPnt& Points,const Standard_Integer DegMin = 3,const Standard_Integer DegMax = 8,const GeomAbs_Shape Continuity = GeomAbs_C2,const Standard_Real Tol3D = 1.0e-3); 26 | GeomAPI_PointsToBSpline(const TColgp_Array1OfPnt& Points,const TColStd_Array1OfReal& Parameters,const Standard_Integer DegMin = 3,const Standard_Integer DegMax = 8,const GeomAbs_Shape Continuity = GeomAbs_C2,const Standard_Real Tol3D = 1.0e-3); 27 | const Handle_Geom_BSplineCurve& Curve() const; 28 | }; 29 | 30 | class GeomAPI_Interpolate { 31 | public: 32 | GeomAPI_Interpolate(const Handle_TColgp_HArray1OfPnt& Points,const Standard_Boolean PeriodicFlag,const Standard_Real Tolerance); 33 | void Load(const TColgp_Array1OfVec& Tangents,const Handle_TColStd_HArray1OfBoolean& TangentFlags,const Standard_Boolean Scale = Standard_True); 34 | void Perform(); 35 | const Handle_Geom_BSplineCurve& Curve() const; 36 | }; 37 | 38 | //%{#include %} 39 | //%rename(TColgp_HArray1OfPnt) Handle_TColgp_HArray1OfPnt; 40 | /* 41 | class Handle_TColgp_HArray1OfPnt 42 | { 43 | Handle_TColgp_HArray1OfPnt()=0; 44 | }; 45 | 46 | %extend Handle_Tcolgp_HArray1OfPnt 47 | { 48 | static Handle_Tcolgp_Harray1OfPnt * hndl() { 49 | 50 | Handle_Tcolgp_Harray1OfPnt 51 | 52 | } 53 | };*/ 54 | /* 55 | %extend Handle_TColgp_HArray1OfPnt 56 | { 57 | static Handle_TColgp_HArray1OfPnt * test(const TColgp_Array1OfPnt& Points) 58 | { 59 | Handle_TColgp_HArray1OfPnt * hgc=new Handle_TColgp_HArray1OfPnt(); 60 | if(hgc->IsNull()) 61 | return NULL; 62 | else 63 | return hgc; 64 | } 65 | }; 66 | */ 67 | 68 | /* 69 | %extend GeomAPI_Interpolate { 70 | 71 | static GeomAPI_Interpolate create(const TColgp_Array1OfPnt& Points,const Standard_Boolean PeriodicFlag,const Standard_Real Tolerance) 72 | { 73 | //TODO: leaks?? 74 | 75 | int i; 76 | Handle(TColgp_HArray1OfPnt) harray = new TColgp_HArray1OfPnt(Points.Lower(),Points.Upper()); 77 | for (i=1;i<=Points.Length(); i++) { 78 | // harray->SetValue(i,Points.Value(i)); 79 | harray->SetValue(i,Points.Value(i)); 80 | } 81 | 82 | return GeomAPI_Interpolate(harray,PeriodicFlag,Tolerance); 83 | 84 | } 85 | };*/ -------------------------------------------------------------------------------- /src/GeomAbs.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | * (C) Copyright 2009, by EADS France 20 | */ 21 | 22 | /** 23 | * GeomAbs_Shape 24 | */ 25 | // rename GeomAbs_Shape to make it more Java friendly 26 | %rename(C0) GeomAbs_C0; 27 | %rename(G1) GeomAbs_G1; 28 | %rename(C1) GeomAbs_C1; 29 | %rename(G2) GeomAbs_G2; 30 | %rename(C2) GeomAbs_C2; 31 | %rename(C3) GeomAbs_C3; 32 | %rename(CN) GeomAbs_CN; 33 | 34 | enum GeomAbs_Shape 35 | { 36 | GeomAbs_C0, 37 | GeomAbs_G1, 38 | GeomAbs_C1, 39 | GeomAbs_G2, 40 | GeomAbs_C2, 41 | GeomAbs_C3, 42 | GeomAbs_CN 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /src/GeomLProp_SLProps.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | /** 22 | * GeomLProp_SLProps 23 | */ 24 | %{#include "GeomLProp_SLProps.hxx"%} 25 | 26 | %typemap(javacode) GeomLProp_SLProps 27 | %{ 28 | /** 29 | * @deprecated Typo mistake in the previous version 30 | */ 31 | public void setParameter(double u, double v) 32 | { 33 | setParameters(u, v); 34 | } 35 | 36 | public double[] normal() 37 | { 38 | double[] toReturn=new double[3]; 39 | normal(toReturn); 40 | return toReturn; 41 | } 42 | 43 | /**Return the normal on the uv nodes.
44 | *Invalid ones are set to zero. 45 | */ 46 | public double[] normalArray(double[] uvNodes) 47 | { 48 | if(uvNodes==null) 49 | throw new NullPointerException(); 50 | 51 | if(uvNodes.length%2!=0) 52 | throw new IllegalArgumentException("uvNodes array length must be peer"); 53 | 54 | int numNodes=uvNodes.length/2; 55 | double[] toReturn=new double[numNodes*3]; 56 | normalArray(uvNodes,toReturn,numNodes); 57 | 58 | return toReturn; 59 | } 60 | 61 | public double[] curvatureDirections() 62 | { 63 | double[] toReturn=new double[6]; 64 | if(isCurvatureDefined()) 65 | { 66 | double[] max=new double[3]; 67 | double[] min=new double[3]; 68 | curvatureDirection(max, min); 69 | System.arraycopy(max, 0, toReturn, 0, 3); 70 | System.arraycopy(min, 0, toReturn, 3, 3); 71 | } 72 | return toReturn; 73 | } 74 | %} 75 | 76 | class GeomLProp_SLProps 77 | { 78 | %rename(setParameters) SetParameters; 79 | %rename(value) Value; 80 | %rename(d1U) D1U; 81 | %rename(d1V) D1V; 82 | %rename(d2U) D2U; 83 | %rename(d2V) D2V; 84 | %rename(dUV) DUV; 85 | %rename(isTangentUDefined) IsTangentUDefined; 86 | %rename(tangentU) TangentU; 87 | %rename(isTangentVDefined) IsTangentVDefined; 88 | %rename(tangentV) TangentV; 89 | %rename(isNormalDefined) IsNormalDefined; 90 | %rename(isCurvatureDefined) IsCurvatureDefined; 91 | %rename(isUmbilic) IsUmbilic; 92 | %rename(meanCurvature) MeanCurvature; 93 | %rename(gaussianCurvature) GaussianCurvature; 94 | %rename(setSurface) SetSurface; 95 | 96 | public: 97 | %javamethodmodifiers GeomLProp_SLProps(const Standard_Integer, const Standard_Real) " 98 | /** 99 | * The current point and the derivatives are computed at the same time, 100 | * which allows an optimization of the computation time. 101 | * @param degree The maximum number of derivations to be done (0, 1, or 2). 102 | * For example, to compute only the tangent, N should be equal to 1. 103 | * @param resolution The linear tolerance (it is used to test if a vector is null). 104 | */ 105 | public"; 106 | 107 | %javamethodmodifiers normalArray(double*, double*, int) "private"; 108 | 109 | GeomLProp_SLProps(const Standard_Integer degree, const Standard_Real resolution); 110 | void SetParameters(const Standard_Real u, const Standard_Real v) ; 111 | const gp_Pnt& Value() const; 112 | const gp_Vec& D1U() ; 113 | const gp_Vec& D1V() ; 114 | const gp_Vec& D2U() ; 115 | const gp_Vec& D2V() ; 116 | const gp_Vec& DUV() ; 117 | Standard_Boolean IsTangentUDefined() ; 118 | void TangentU(gp_Dir& D) ; 119 | Standard_Boolean IsTangentVDefined() ; 120 | void TangentV(gp_Dir& D) ; 121 | Standard_Boolean IsNormalDefined() ; 122 | Standard_Boolean IsCurvatureDefined() ; 123 | Standard_Boolean IsUmbilic() ; 124 | Standard_Real MeanCurvature() ; 125 | Standard_Real GaussianCurvature() ; 126 | void SetSurface(const Handle_Geom_Surface & S) ; 127 | }; 128 | 129 | %extend GeomLProp_SLProps 130 | { 131 | void normal(double normal[3]) 132 | { 133 | if(!self->IsNormalDefined()) 134 | { 135 | normal[0]=0; 136 | normal[1]=0; 137 | normal[2]=0; 138 | } 139 | else 140 | { 141 | const gp_Dir & d=self->Normal(); 142 | normal[0]=d.X(); 143 | normal[1]=d.Y(); 144 | normal[2]=d.Z(); 145 | } 146 | } 147 | 148 | void normalArray(double* uvNodes,double* normalArray,int numNodes) 149 | { 150 | for(int i=0;iSetParameters(uvNodes[2*i],uvNodes[2*i+1]); 153 | 154 | if(!self->IsNormalDefined()) 155 | { 156 | normalArray[3*i]=0; 157 | normalArray[3*i+1]=0; 158 | normalArray[3*i+2]=0; 159 | } 160 | else 161 | { 162 | const gp_Dir & d=self->Normal(); 163 | 164 | normalArray[3*i]=d.X(); 165 | normalArray[3*i+1]=d.Y(); 166 | normalArray[3*i+2]=d.Z(); 167 | } 168 | } 169 | } 170 | 171 | Standard_Real minCurvature() 172 | { 173 | if (!self->IsCurvatureDefined()) 174 | return sqrt(-1.0); 175 | else 176 | return self->MinCurvature (); 177 | } 178 | 179 | Standard_Real maxCurvature() 180 | { 181 | if (!self->IsCurvatureDefined()) 182 | return sqrt(-1.0); 183 | else 184 | return self->MaxCurvature (); 185 | } 186 | 187 | void curvatureDirection(double jmax[3], double jmin[3]) 188 | { 189 | gp_Dir max, min; 190 | self->CurvatureDirections(max, min); 191 | jmax[0]=max.X(); 192 | jmax[1]=max.Y(); 193 | jmax[2]=max.Z(); 194 | jmin[0]=min.X(); 195 | jmin[1]=min.Y(); 196 | jmin[2]=min.Z(); 197 | } 198 | }; 199 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES=libOccJava.la 2 | 3 | IFACEFILES=\ 4 | BRepPrimAPI.i \ 5 | BRep.i \ 6 | BRepTools.i \ 7 | GeomLProp_SLProps.i \ 8 | gp.i OccJava.i \ 9 | Standard.i \ 10 | TopAbs.i \ 11 | TopoDS.i \ 12 | BRepAlgoAPI.i \ 13 | Poly.i \ 14 | Geom.i \ 15 | BRepBuilderAPI.i \ 16 | TopTools.i \ 17 | GeomAbs.i \ 18 | BRepLib.i \ 19 | BRepFilletAPI.i \ 20 | ShapeUpgrade.i \ 21 | XSControl.i \ 22 | ShapeFix.i 23 | 24 | BUILT_SOURCES = OccJava_wrap.cxx 25 | JAVAGENSRCDIR=$(top_srcdir)/src-java/org/jcae/opencascade/jni/ 26 | 27 | $(BUILT_SOURCES) : $(IFACEFILES) 28 | echo "Running swig on $(IFACEFILES)" 29 | mkdir -p $(JAVAGENSRCDIR) 30 | swig -c++ -v $(CPPFLAGS) -Wall -java -package org.jcae.opencascade.jni -outdir $(JAVAGENSRCDIR) OccJava.i 31 | 32 | libOccJava_la_SOURCES = $(BUILT_SOURCES) jnistream.cxx 33 | 34 | CLEANFILES=OccJava_wrap.cxx 35 | 36 | -------------------------------------------------------------------------------- /src/OccJava.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | * (C) Copyright 2008, 2009, by EADS France 20 | */ 21 | 22 | %module OccJava 23 | 24 | %{ 25 | #ifdef HAVE_CONFIG_H 26 | //config.h generated by autotools from config.h.in (see an example in Opencascade). 27 | #include "config.h" 28 | #endif 29 | #include 30 | #include 31 | #include 32 | %} 33 | 34 | // Handle enums with Java enums 35 | %javaconst(1); 36 | %include "enums.swg" 37 | 38 | // Handle C arrays as Java arrays 39 | %include "arrays_java.i"; 40 | %apply double[] {double *}; 41 | %apply double[] {double &}; 42 | 43 | // load the native library 44 | %pragma(java) jniclasscode=%{ 45 | static 46 | { 47 | System.loadLibrary("OccJava"); 48 | if(!"0".equals(System.getenv("MMGT_OPT"))) 49 | throw new RuntimeException("The MMGT_OPT environement variable must be set to 0 before using occjava."); 50 | } 51 | %} 52 | 53 | %include "Standard.i" 54 | %include "gp.i" 55 | %include "TCol.i" 56 | %include "TopAbs.i" 57 | %include "TopoDS.i" 58 | %include "GeomAbs.i" 59 | %include "TopTools.i" 60 | %include "BRep.i" 61 | %include "GeomLProp_SLProps.i" 62 | %include "BRepTools.i" 63 | %include "BRepBuilderAPI.i" 64 | %include "BRepOffsetAPI.i" 65 | %include "BRepPrimAPI.i" 66 | %include "BRepAlgoAPI.i" 67 | %include "Poly.i" 68 | %include "Geom.i" 69 | %include "BRepLib.i" 70 | %include "BRepFilletAPI.i" 71 | %include "BRepCheck.i" 72 | %include "ShapeBuild.i" 73 | %include "XSControl.i" 74 | %include "ShapeFix.i" 75 | %include "ShapeAnalysis.i" 76 | %include "APIHeaderSection_MakeHeader.i" 77 | // This one require Opencascade 6.2 78 | %include "ShapeUpgrade.i" 79 | //Jens Schmidt, req. f. Thesis 80 | %include "GeomAPI.i" 81 | %include "GC.i" 82 | 83 | %typemap(javacode) TopExp 84 | %{ 85 | public static TopoDS_Vertex[] vertices(TopoDS_Edge edge, boolean cumOri) 86 | { 87 | TopoDS_Vertex first=new TopoDS_Vertex(); 88 | TopoDS_Vertex second=new TopoDS_Vertex(); 89 | vertices(edge, first, second, cumOri); 90 | return new TopoDS_Vertex[]{first, second}; 91 | } 92 | %} 93 | 94 | class TopLoc_Location 95 | { 96 | %rename(isIdentity) IsIdentity; 97 | %rename(transformation) Transformation; 98 | public: 99 | TopLoc_Location (); 100 | TopLoc_Location (const gp_Trsf& T); 101 | Standard_Boolean IsIdentity(); 102 | const gp_Trsf& Transformation(); 103 | }; 104 | 105 | class TopExp 106 | { 107 | public: 108 | %rename(vertices) Vertices; 109 | %rename(commonVertex) CommonVertex; 110 | static void Vertices(const TopoDS_Edge& E,TopoDS_Vertex& Vfirst,TopoDS_Vertex& Vlast,const Standard_Boolean CumOri = Standard_False) ; 111 | static Standard_Boolean CommonVertex(const TopoDS_Edge& E1, const TopoDS_Edge& E2, TopoDS_Vertex& V) ; 112 | }; 113 | 114 | /** 115 | * TopExp_Explorer 116 | */ 117 | %{#include "TopExp_Explorer.hxx"%} 118 | class TopExp_Explorer 119 | { 120 | public: 121 | TopExp_Explorer(); 122 | TopExp_Explorer(const TopoDS_Shape& S,const TopAbs_ShapeEnum ToFind, 123 | const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE); 124 | %rename(init) Init; 125 | %rename(more) More; 126 | %rename(next) Next; 127 | %rename(current) Current; 128 | void Init(const TopoDS_Shape& S, const TopAbs_ShapeEnum ToFind, 129 | const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE) ; 130 | Standard_Boolean More() const; 131 | void Next() ; 132 | const TopoDS_Shape & Current(); 133 | }; 134 | 135 | /** 136 | * Bnd_Box 137 | */ 138 | %{#include "Bnd_Box.hxx"%} 139 | %typemap(javacode) Bnd_Box 140 | %{ 141 | /** 142 | * Return the array { Xmin, Ymin, Zmin, Xmax, Ymax, Zmax } 143 | */ 144 | public double[] get() 145 | { 146 | double[] toReturn=new double[6]; 147 | get(toReturn); 148 | return toReturn; 149 | } 150 | %} 151 | 152 | class Bnd_Box 153 | { 154 | %rename(isVoid) IsVoid; 155 | public: 156 | Bnd_Box(); 157 | Standard_Boolean IsVoid() const; 158 | }; 159 | 160 | %extend Bnd_Box 161 | { 162 | void get(double box[6]) 163 | { 164 | if(!self->IsVoid()) 165 | self->Get(box[0], box[1], box[2], box[3], box[4], box[5]); 166 | } 167 | }; 168 | 169 | /** 170 | * BRepBndLib 171 | */ 172 | %{#include "BRepBndLib.hxx"%} 173 | class BRepBndLib 174 | { 175 | public: 176 | %rename(add) Add; 177 | static void Add(const TopoDS_Shape& shape,Bnd_Box& bndBox); 178 | }; 179 | 180 | /** 181 | * Adaptor2d_Curve2d 182 | */ 183 | %{#include "Adaptor2d_Curve2d.hxx"%} 184 | 185 | class Adaptor2d_Curve2d 186 | { 187 | Adaptor2d_Curve2d()=0; 188 | public: 189 | %rename(value) Value; 190 | virtual gp_Pnt2d Value(const Standard_Real U) const; 191 | }; 192 | 193 | /** 194 | * Geom2dAdaptor_Curve 195 | */ 196 | %{#include "Geom2dAdaptor_Curve.hxx"%} 197 | class Geom2dAdaptor_Curve: public Adaptor2d_Curve2d 198 | { 199 | %rename(load) Load; 200 | public: 201 | Geom2dAdaptor_Curve(); 202 | Geom2dAdaptor_Curve(const Handle_Geom2d_Curve & C); 203 | Geom2dAdaptor_Curve(const Handle_Geom2d_Curve & C,const Standard_Real UFirst,const Standard_Real ULast); 204 | void Load(const Handle_Geom2d_Curve & C) ; 205 | void Load(const Handle_Geom2d_Curve & C,const Standard_Real UFirst,const Standard_Real ULast) ; 206 | }; 207 | 208 | /** 209 | * Adaptor3d_Curve 210 | */ 211 | %{#include "Adaptor3d_Curve.hxx"%} 212 | 213 | class Adaptor3d_Curve 214 | { 215 | Adaptor3d_Curve()=0; 216 | public: 217 | %rename(value) Value; 218 | const gp_Pnt Value(const Standard_Real U) const; 219 | }; 220 | 221 | //extends the Adaptor3d_Curve class to reduce the JNI overhead when 222 | //calling a lot of Adaptor3d_Curve.Value 223 | %extend Adaptor3d_Curve 224 | { 225 | public: 226 | void arrayValues(int size, double u[]) 227 | { 228 | for (int i = 0; i < size; i++) 229 | { 230 | gp_Pnt gp=self->Value(u[3*i]); 231 | u[3*i] = gp.X(); 232 | u[3*i+1] = gp.Y(); 233 | u[3*i+2] = gp.Z(); 234 | } 235 | } 236 | }; 237 | 238 | /** 239 | * GeomAdaptor_Curve 240 | */ 241 | %{#include "GeomAdaptor_Curve.hxx"%} 242 | 243 | class GeomAdaptor_Curve: public Adaptor3d_Curve 244 | { 245 | %rename(load) Load; 246 | public: 247 | GeomAdaptor_Curve(); 248 | GeomAdaptor_Curve(const Handle_Geom_Curve & C); 249 | GeomAdaptor_Curve(const Handle_Geom_Curve & C, 250 | const Standard_Real UFirst,const Standard_Real ULast); 251 | void Load(const Handle_Geom_Curve & C) ; 252 | void Load(const Handle_Geom_Curve & C, 253 | const Standard_Real UFirst,const Standard_Real ULast) ; 254 | 255 | }; 256 | 257 | 258 | /** 259 | * GProp_GProps 260 | */ 261 | %{#include "GProp_GProps.hxx"%} 262 | class GProp_GProps 263 | { 264 | public: 265 | %rename(mass) Mass; 266 | GProp_GProps(); 267 | Standard_Real Mass() const; 268 | }; 269 | 270 | /** 271 | * BRepGProp 272 | */ 273 | %{#include "BRepGProp.hxx"%} 274 | class BRepGProp 275 | { 276 | public: 277 | %rename(linearProperties) LinearProperties; 278 | %rename(surfaceProperties) SurfaceProperties; 279 | %rename(volumeProperties) VolumeProperties; 280 | static void LinearProperties(const TopoDS_Shape& shape, GProp_GProps& properties); 281 | static void VolumeProperties(const TopoDS_Shape& shape, GProp_GProps& properties, const Standard_Boolean onlyClosed = Standard_False) ; 282 | static Standard_Real VolumeProperties(const TopoDS_Shape& shape, GProp_GProps& properties, const Standard_Real Eps, const Standard_Boolean onlyClosed = Standard_False) ; 283 | static void SurfaceProperties(const TopoDS_Shape& shape, GProp_GProps& properties) ; 284 | static Standard_Real SurfaceProperties(const TopoDS_Shape& shape, GProp_GProps& properties, const Standard_Real Eps) ; 285 | }; 286 | 287 | /** 288 | * 289 | */ 290 | %rename(VOID) IFSelect_RetVoid; 291 | %rename(DONE) IFSelect_RetDone; 292 | %rename(ERROR) IFSelect_RetError; 293 | %rename(FAIL) IFSelect_RetFail; 294 | %rename(STOP) IFSelect_RetStop; 295 | enum IFSelect_ReturnStatus { 296 | IFSelect_RetVoid, 297 | IFSelect_RetDone, 298 | IFSelect_RetError, 299 | IFSelect_RetFail, 300 | IFSelect_RetStop 301 | }; 302 | 303 | %{#include %} 304 | class ShapeAnalysis_FreeBounds 305 | { 306 | %rename(getClosedWires) GetClosedWires; 307 | %rename(getOpenWires) GetOpenWires; 308 | public: 309 | ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape, 310 | const Standard_Boolean splitclosed = Standard_False, 311 | const Standard_Boolean splitopen = Standard_True); 312 | const TopoDS_Compound& GetClosedWires() const; 313 | const TopoDS_Compound& GetOpenWires() const; 314 | }; 315 | 316 | %{#include %} 317 | class GCPnts_UniformDeflection 318 | { 319 | %rename(initialize) Initialize; 320 | %rename(nbPoints) NbPoints; 321 | %rename(parameter) Parameter; 322 | public: 323 | GCPnts_UniformDeflection(); 324 | void Initialize(Adaptor3d_Curve& C,const Standard_Real Deflection, 325 | const Standard_Real U1,const Standard_Real U2, 326 | const Standard_Boolean WithControl = Standard_True) ; 327 | Standard_Integer NbPoints() const; 328 | Standard_Real Parameter(const Standard_Integer Index) const; 329 | }; 330 | 331 | %{#include %} 332 | class BRepMesh_DiscretRoot 333 | { 334 | %rename(setDeflection) SetDeflection; 335 | %rename(setAngle) SetAngle; 336 | %rename(deflection) Deflection; 337 | %rename(angle) Angle; 338 | %rename(perform) Perform; 339 | 340 | protected: 341 | BRepMesh_DiscretRoot(); 342 | public: 343 | void SetDeflection(const Standard_Real D) ; 344 | void SetAngle(const Standard_Real Ang) ; 345 | Standard_Real Deflection() const; 346 | Standard_Real Angle() const; 347 | virtual void Perform(); 348 | }; 349 | 350 | %{#include %} 351 | class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot 352 | { 353 | %rename(perform) Perform; 354 | // %rename(update) Update; 355 | %rename(isModified) IsModified; 356 | 357 | public: 358 | BRepMesh_IncrementalMesh(); 359 | BRepMesh_IncrementalMesh(const TopoDS_Shape& S,const Standard_Real D, 360 | const Standard_Boolean Relatif = Standard_False, 361 | const Standard_Real Ang = 0.5); 362 | 363 | void Perform(); 364 | // void Update(const TopoDS_Shape& S) ; 365 | Standard_Boolean IsModified() const; 366 | }; 367 | 368 | %{#include %} 369 | 370 | %typemap(javacode) GeomAPI_ProjectPointOnSurf 371 | %{ 372 | public void lowerDistanceParameters(double[] uv) 373 | { 374 | double[] d2=new double[1]; 375 | lowerDistanceParameters(uv, d2); 376 | uv[1]=d2[0]; 377 | } 378 | %} 379 | 380 | class GeomAPI_ProjectPointOnSurf 381 | { 382 | %rename(init) Init; 383 | %rename(nbPoints) NbPoints; 384 | %rename(lowerDistanceParameters) LowerDistanceParameters; 385 | %rename(lowerDistance) LowerDistance; 386 | %rename(point) Point; 387 | %rename(parameters) Parameters; 388 | %rename(nearestPoint) NearestPoint; 389 | public: 390 | GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, 391 | const Handle_Geom_Surface & Surface); 392 | void Init(const gp_Pnt& P,const Handle_Geom_Surface & surface); 393 | Standard_Integer NbPoints() const; 394 | Quantity_Length LowerDistance() const; 395 | const gp_Pnt Point(const Standard_Integer Index) const; 396 | void LowerDistanceParameters(Quantity_Parameter& U,Quantity_Parameter& V) const; 397 | void Parameters(const Standard_Integer Index,Quantity_Parameter& U,Quantity_Parameter& V) const; 398 | gp_Pnt NearestPoint() const; 399 | }; 400 | 401 | /** 402 | * BRepAlgo 403 | */ 404 | %{#include %} 405 | class BRepAlgo 406 | { 407 | %rename(isValid) IsValid; 408 | %rename(isTopologicallyValid) IsTopologicallyValid; 409 | public: 410 | static Standard_Boolean IsValid(const TopoDS_Shape& S); 411 | static Standard_Boolean IsTopologicallyValid(const TopoDS_Shape& S); 412 | }; 413 | -------------------------------------------------------------------------------- /src/Poly.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{#include %} 22 | 23 | %typemap(jni) Poly_Array1OfTriangle& "jintArray" 24 | %typemap(jtype) Poly_Array1OfTriangle& "int[]" 25 | %typemap(jstype) Poly_Array1OfTriangle& "int[]" 26 | %typemap(javaout) Poly_Array1OfTriangle& 27 | { 28 | return $jnicall; 29 | } 30 | 31 | %typemap(out) const Poly_Array1OfTriangle& 32 | { 33 | int i,j,s; 34 | const Poly_Array1OfTriangle &Triangles = *$1; 35 | s=Triangles.Length()*3; 36 | jint * iarray=new jint[s]; 37 | Standard_Integer n1,n2,n3; 38 | 39 | for(j=0,i=Triangles.Lower();i<=Triangles.Upper();j+=3,i++) 40 | { 41 | Triangles(i).Get(n1,n2,n3); 42 | iarray[j]=n1-1; 43 | iarray[j+1]=n2-1; 44 | iarray[j+2]=n3-1; 45 | } 46 | 47 | jintArray array=JCALL1(NewIntArray, jenv, s); 48 | JCALL4(SetIntArrayRegion, jenv, array, 0, s, iarray); 49 | delete[] iarray; 50 | $result=array; 51 | } 52 | 53 | class Poly_Triangulation 54 | { 55 | %rename(deflection) Deflection; 56 | %rename(removeUVNodes) RemoveUVNodes; 57 | %rename(nbNodes) NbNodes; 58 | %rename(hasUVNodes) HasUVNodes; 59 | %rename(nbTriangles) NbTriangles; 60 | %rename(triangles) Triangles; 61 | %rename(nodes) Nodes; 62 | %rename(uvNodes) UVNodes; 63 | 64 | public: 65 | Poly_Triangulation(const Standard_Integer nbNodes, 66 | const Standard_Integer nbTriangles,const Standard_Boolean UVNodes); 67 | Standard_Real Deflection() const; 68 | void Deflection(const Standard_Real D) ; 69 | void RemoveUVNodes() ; 70 | Standard_Integer NbNodes() const; 71 | Standard_Integer NbTriangles() const; 72 | Standard_Boolean HasUVNodes() const; 73 | const Poly_Array1OfTriangle& Triangles() const; 74 | const TColgp_Array1OfPnt& Nodes() const; 75 | const TColgp_Array1OfPnt2d& UVNodes() const; 76 | }; 77 | -------------------------------------------------------------------------------- /src/ShapeAnalysis.i: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or modify it under 3 | * the terms of the GNU Lesser General Public License as published by the Free 4 | * Software Foundation; either version 2.1 of the License, or (at your option) 5 | * any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 10 | * details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this program; if not, write to the Free Software Foundation, Inc., 14 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 15 | * 16 | * (C) Copyright 2015, by fortiss GmbH, Alexander Perzylo 17 | */ 18 | 19 | %{ 20 | #include 21 | #include 22 | %} 23 | 24 | class ShapeAnalysis_Edge 25 | { 26 | public: 27 | 28 | %rename(hasPCurve) HasPCurve; 29 | %rename(isClosed3d) IsClosed3d; 30 | %rename(IsSeam) IsSeam; 31 | 32 | ShapeAnalysis_Edge(); 33 | 34 | Standard_Boolean IsClosed3d (const TopoDS_Edge &edge) const ; 35 | Standard_Boolean HasPCurve (const TopoDS_Edge &edge, const TopoDS_Face &face) const ; 36 | Standard_Boolean IsSeam (const TopoDS_Edge &edge, const TopoDS_Face &face) const ; 37 | 38 | }; 39 | 40 | class ShapeAnalysis_Surface 41 | { 42 | public: 43 | 44 | %rename(hasSingularities) HasSingularities; 45 | %rename(getNbSingularities) NbSingularities; 46 | %rename(isDegenerated) IsDegenerated; 47 | 48 | ShapeAnalysis_Surface (const Handle_Geom_Surface &S); 49 | 50 | Standard_Boolean HasSingularities (const Standard_Real preci) ; 51 | Standard_Integer NbSingularities (const Standard_Real preci) ; 52 | Standard_Boolean IsDegenerated (const gp_Pnt &P3d, const Standard_Real preci) ; 53 | 54 | }; 55 | 56 | -------------------------------------------------------------------------------- /src/ShapeBuild.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2007, by EADS France 19 | */ 20 | 21 | %{#include %} 22 | 23 | class ShapeBuild_ReShape 24 | { 25 | public: 26 | 27 | %rename(replace) Replace; 28 | %rename(apply) Apply; 29 | 30 | ShapeBuild_ReShape(); 31 | void Replace(const TopoDS_Shape& shape,const TopoDS_Shape& newshape,const Standard_Boolean oriented = Standard_False) ; 32 | TopoDS_Shape Apply(const TopoDS_Shape& shape,const TopAbs_ShapeEnum until = TopAbs_SHAPE) ; 33 | }; 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/ShapeFix.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2007, by EADS France 19 | */ 20 | 21 | %{ 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | %} 33 | 34 | %rename(Message_ProgressIndicator) Handle_Message_ProgressIndicator; 35 | %rename(ShapeFix_Solid) Handle_ShapeFix_Solid; 36 | %rename(ShapeFix_Shell) Handle_ShapeFix_Shell; 37 | %rename(ShapeFix_Face) Handle_ShapeFix_Face; 38 | %rename(ShapeFix_Wire) Handle_ShapeFix_Wire; 39 | %rename(ShapeFix_Edge) Handle_ShapeFix_Edge; 40 | 41 | class ShapeFix_Root 42 | { 43 | ShapeFix_Root()=0; 44 | public: 45 | %rename(setPrecision) SetPrecision; 46 | %rename(getPrecision) Precision; 47 | %rename(setContext) SetContext; 48 | void SetPrecision(const Standard_Real preci) ; 49 | Standard_Real Precision() const; 50 | void SetContext(const ShapeBuild_ReShape * context) ; 51 | }; 52 | 53 | %extend ShapeFix_Root 54 | { 55 | ShapeBuild_ReShape * getContext() 56 | { 57 | Standard_Transient * p = self->Context(); 58 | return dynamic_cast(p); 59 | } 60 | } 61 | 62 | class ShapeFix_Wireframe: public ShapeFix_Root 63 | { 64 | 65 | public: 66 | ShapeFix_Wireframe(const TopoDS_Shape& shape); 67 | %rename(fixWireGaps) FixWireGaps; 68 | %rename(fixSmallEdges) FixSmallEdges; 69 | %rename(setLimitAngle) SetLimitAngle; 70 | %rename(getLimitAngle) LimitAngle; 71 | %rename(shape) Shape; 72 | %javamethodmodifiers FixWireGaps() " 73 | /** 74 | * Fixes gaps between ends of curves of adjacent edges (both 3d and pcurves) 75 | * in wires. If precision is 0.0, uses Precision::Confusion(). 76 | */ 77 | public"; 78 | Standard_Boolean FixWireGaps(); 79 | 80 | %javamethodmodifiers FixSmallEdges() " 81 | /** 82 | * Fixes small edges in shape by merging adjacent edges. 83 | * If precision is 0.0, uses Precision::Confusion(). 84 | */ 85 | public"; 86 | Standard_Boolean FixSmallEdges() ; 87 | 88 | %javamethodmodifiers SetLimitAngle(const Standard_Real theLimitAngle) " 89 | /** 90 | * If two edges makes an angle greater this angle, these two edges 91 | * will be not merged. 92 | */ 93 | public"; 94 | void SetLimitAngle(const Standard_Real theLimitAngle) ; 95 | Standard_Real LimitAngle() const; 96 | TopoDS_Shape Shape() ; 97 | }; 98 | 99 | %extend ShapeFix_Wireframe 100 | { 101 | void setDropSmallEdges(bool b) 102 | { 103 | self->ModeDropSmallEdges()=b; 104 | } 105 | bool getDropSmallEdges() 106 | { 107 | return self->ModeDropSmallEdges()!=0; 108 | } 109 | }; 110 | 111 | class ShapeFix_Shape 112 | { 113 | public: 114 | ShapeFix_Shape(const TopoDS_Shape& shape)=0; 115 | 116 | %rename(getShape) Shape; 117 | %rename(perform) Perform; 118 | %rename(getFixSolidTool) FixSolidTool; 119 | %rename(getFixShellTool) FixShellTool; 120 | %rename(getFixFaceTool) FixFaceTool; 121 | %rename(getFixWireTool) FixWireTool; 122 | %rename(getFixEdgeTool) FixEdgeTool; 123 | 124 | TopoDS_Shape Shape() const ; 125 | Standard_Boolean Perform (const Handle_Message_ProgressIndicator& theProgress=0) ; 126 | Handle_ShapeFix_Solid FixSolidTool() const ; 127 | Handle_ShapeFix_Shell FixShellTool() const ; 128 | Handle_ShapeFix_Face FixFaceTool() const ; 129 | Handle_ShapeFix_Wire FixWireTool() const ; 130 | Handle_ShapeFix_Edge FixEdgeTool() const ; 131 | 132 | }; 133 | -------------------------------------------------------------------------------- /src/ShapeUpgrade.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2007, by EADS France 19 | */ 20 | 21 | %{ #include %} 22 | %{ #include %} 23 | %{ #include %} 24 | class ShapeUpgrade_Tool 25 | { 26 | ShapeUpgrade_Tool()=0; 27 | }; 28 | 29 | class ShapeUpgrade_RemoveInternalWires : public ShapeUpgrade_Tool 30 | { 31 | public: 32 | %rename(perform) Perform; 33 | %rename(getResult) GetResult; 34 | ShapeUpgrade_RemoveInternalWires(const TopoDS_Shape& theShape); 35 | Standard_Boolean Perform() ; 36 | TopoDS_Shape GetResult() const; 37 | }; 38 | 39 | %extend ShapeUpgrade_RemoveInternalWires 40 | { 41 | void setMinArea(double d) 42 | { 43 | self->MinArea()=d; 44 | } 45 | 46 | double getMinArea() 47 | { 48 | return self->MinArea(); 49 | } 50 | 51 | void setRemoveFaceMode(Standard_Boolean b) 52 | { 53 | self->RemoveFaceMode()=b; 54 | } 55 | 56 | Standard_Boolean getRemoveFaceMode() 57 | { 58 | return self->RemoveFaceMode(); 59 | } 60 | }; 61 | 62 | class ShapeUpgrade_ShapeDivide 63 | { 64 | public: 65 | %rename(getResult) Result; 66 | %rename(perform) Perform; 67 | TopoDS_Shape Result() const; 68 | Standard_Boolean Perform(const Standard_Boolean newContext = Standard_True) ; 69 | }; 70 | 71 | class ShapeUpgrade_ShapeDivideArea : public ShapeUpgrade_ShapeDivide 72 | { 73 | public: 74 | ShapeUpgrade_ShapeDivideArea(const TopoDS_Shape& S); 75 | }; 76 | 77 | %extend ShapeUpgrade_ShapeDivideArea 78 | { 79 | void setMaxArea(double d) 80 | { 81 | self->MaxArea()=d; 82 | } 83 | 84 | double getMaxArea() 85 | { 86 | return self->MaxArea(); 87 | } 88 | }; 89 | 90 | -------------------------------------------------------------------------------- /src/Standard.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | //Refine the catch keywoard 22 | %{#include %} 23 | 24 | /*%exception 25 | { 26 | try 27 | { 28 | $action 29 | } 30 | catch(Standard_Failure) 31 | { 32 | SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, Standard_Failure::Caught()->DynamicType()->Name()); 33 | return $null; 34 | } 35 | }*/ 36 | // Now we bind Opencascade types with Java types. 37 | // /usr/share/swig1.3/java/java.swg contains many simple example to do that. 38 | /** 39 | * Standard_CString 40 | */ 41 | %typemap(jni) Standard_CString "jstring" 42 | %typemap(jtype) Standard_CString "String" 43 | %typemap(jstype) Standard_CString "String" 44 | 45 | %typemap(in) Standard_CString 46 | { 47 | $1 = const_cast<$1_ltype>(JCALL2(GetStringUTFChars, jenv, $input, 0)); 48 | } 49 | 50 | %typemap(out) Standard_CString %{ #error TODO %} 51 | 52 | %typemap(javain) Standard_CString "$javainput" 53 | %typemap(javaout) Standard_CString 54 | { 55 | return $jnicall; 56 | } 57 | 58 | /** 59 | * Standard_Boolean 60 | */ 61 | %typemap(jni) Standard_Boolean "jboolean" 62 | %typemap(jtype) Standard_Boolean "boolean" 63 | %typemap(jstype) Standard_Boolean "boolean" 64 | 65 | %typemap(in) Standard_Boolean 66 | { 67 | $1 = $input; 68 | } 69 | 70 | %typemap(out) Standard_Boolean %{ $result = (jboolean)$1; %} 71 | 72 | %typemap(javain) Standard_Boolean "$javainput" 73 | %typemap(javaout) Standard_Boolean 74 | { 75 | return $jnicall; 76 | } 77 | 78 | %typedef double Standard_Real; 79 | %typedef int Standard_Integer; 80 | %typedef double Quantity_Length; 81 | %typedef double Quantity_Parameter; 82 | 83 | /** 84 | * Standard_OStream 85 | */ 86 | %{ #include "jnistream.hxx" %} 87 | %typemap(jni) Standard_OStream& "jobject" 88 | %typemap(jtype) Standard_OStream& "java.nio.channels.WritableByteChannel" 89 | %typemap(jstype) Standard_OStream& "java.nio.channels.WritableByteChannel" 90 | 91 | %typemap(in) Standard_OStream& 92 | %{ 93 | jnistreambuf buf(jenv, $input); 94 | Standard_OStream os(&buf); 95 | $1=&os; 96 | %} 97 | 98 | %typemap(freearg) Standard_OStream& 99 | %{ 100 | $1->flush(); 101 | %} 102 | 103 | %typemap(javain) Standard_OStream& "$javainput" 104 | %typemap(javaout) Standard_OStream& 105 | { 106 | return $jnicall; 107 | } 108 | 109 | /** 110 | * Standard_IStream 111 | */ 112 | %typemap(jni) Standard_IStream& "jobject" 113 | %typemap(jtype) Standard_IStream& "java.nio.channels.ReadableByteChannel" 114 | %typemap(jstype) Standard_IStream& "java.nio.channels.ReadableByteChannel" 115 | 116 | %typemap(in) Standard_IStream& 117 | %{ 118 | jnistreambuf buf(jenv, $input); 119 | Standard_IStream is(&buf); 120 | $1=&is; 121 | %} 122 | 123 | %typemap(javain) Standard_IStream& "$javainput" 124 | %typemap(javaout) Standard_IStream& 125 | { 126 | return $jnicall; 127 | } 128 | 129 | -------------------------------------------------------------------------------- /src/TopAbs.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | /** 22 | * Shape_Enum 23 | */ 24 | // rename ShapeEnum so it match first implementation of libOccJava 25 | %rename(COMPOUND) TopAbs_COMPOUND; 26 | %rename(COMPSOLID) TopAbs_COMPSOLID; 27 | %rename(SOLID) TopAbs_SOLID; 28 | %rename(SHELL) TopAbs_SHELL; 29 | %rename(FACE) TopAbs_FACE; 30 | %rename(WIRE) TopAbs_WIRE; 31 | %rename(EDGE) TopAbs_EDGE; 32 | %rename(VERTEX) TopAbs_VERTEX; 33 | %rename(SHAPE) TopAbs_SHAPE; 34 | 35 | enum TopAbs_ShapeEnum 36 | { 37 | TopAbs_COMPOUND, 38 | TopAbs_COMPSOLID, 39 | TopAbs_SOLID, 40 | TopAbs_SHELL, 41 | TopAbs_FACE, 42 | TopAbs_WIRE, 43 | TopAbs_EDGE, 44 | TopAbs_VERTEX, 45 | TopAbs_SHAPE 46 | }; 47 | 48 | %rename(FORWARD) TopAbs_FORWARD; 49 | %rename(REVERSED) TopAbs_REVERSED; 50 | %rename(INTERNAL) TopAbs_INTERNAL; 51 | %rename(EXTERNAL) TopAbs_EXTERNAL; 52 | enum TopAbs_Orientation 53 | { 54 | TopAbs_FORWARD, 55 | TopAbs_REVERSED, 56 | TopAbs_INTERNAL, 57 | TopAbs_EXTERNAL 58 | }; 59 | -------------------------------------------------------------------------------- /src/TopTools.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | */ 20 | 21 | %{ 22 | #include 23 | %} 24 | 25 | %typemap(jni) const TopTools_ListOfShape& "jlongArray" 26 | %typemap(jtype) const TopTools_ListOfShape& "long[]" 27 | %typemap(jstype) const TopTools_ListOfShape& "TopoDS_Shape[]" 28 | 29 | %typemap(javain) const TopTools_ListOfShape& "TopoDS_Shape.cArrayUnwrap($javainput)" 30 | %typemap(javaout) const TopTools_ListOfShape& 31 | { 32 | return TopoDS_Shape.cArrayWrap($jnicall); 33 | } 34 | %typemap(in) const TopTools_ListOfShape& (jlong *jarr, jsize sz) 35 | { 36 | int i; 37 | if (!$input) 38 | { 39 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); 40 | return $null; 41 | } 42 | sz = JCALL1(GetArrayLength, jenv, $input); 43 | jarr = JCALL2(GetLongArrayElements, jenv, $input, 0); 44 | if (!jarr) 45 | { 46 | return $null; 47 | } 48 | $1 = new TopTools_ListOfShape(); 49 | for (i=0; iAppend(*(TopoDS_Shape*)jarr[i]); 52 | } 53 | } 54 | 55 | %typemap(freearg) const TopTools_ListOfShape& 56 | %{ 57 | delete $1; 58 | %} 59 | 60 | %{#include %} 61 | %typemap(out) const TopTools_ListOfShape& 62 | { 63 | int j,n; 64 | const TopTools_ListOfShape& l = *$1; 65 | n = l.Extent(); 66 | jlong * as=(jlong*) malloc (sizeof(jlong) * n * 2); 67 | TopTools_ListIteratorOfListOfShape it(l); 68 | j=0; 69 | while(it.More()) 70 | { 71 | const TopoDS_Shape & s=it.Value(); 72 | TopoDS_Shape * tsp=new TopoDS_Shape(); 73 | tsp->TShape(s.TShape()); 74 | tsp->Location(s.Location()); 75 | tsp->Orientation(s.Orientation()); 76 | as[j++]=(jlong)tsp; 77 | as[j++]=s.ShapeType(); 78 | it.Next(); 79 | } 80 | jlongArray jarray=JCALL1(NewLongArray, jenv, n*2); 81 | JCALL4(SetLongArrayRegion, jenv, jarray, 0, n*2, as); 82 | free(as); 83 | $result=jarray; 84 | } 85 | 86 | class TopTools_HSequenceOfShape 87 | { 88 | public: 89 | TopTools_HSequenceOfShape(); 90 | Standard_Boolean IsEmpty () const; 91 | Standard_Integer Length () const; 92 | void Clear (); 93 | void Append (const TopoDS_Shape& anItem); 94 | void Prepend (const TopoDS_Shape& anItem); 95 | void Reverse (); 96 | void InsertBefore (const Standard_Integer anIndex, const TopoDS_Shape &anItem); 97 | void InsertAfter (const Standard_Integer anIndex, const TopoDS_Shape &anItem); 98 | void Exchange (const Standard_Integer anIndex, const Standard_Integer anOtherIndex); 99 | void SetValue (const Standard_Integer anIndex, const TopoDS_Shape& anItem); 100 | const TopoDS_Shape& Value (const Standard_Integer anIndex) const; 101 | TopoDS_Shape& ChangeValue (const Standard_Integer anIndex); 102 | void Remove (const Standard_Integer anIndex); 103 | void Remove (const Standard_Integer fromIndex, const Standard_Integer toIndex); 104 | const TopTools_SequenceOfShape& Sequence () const ; 105 | }; 106 | -------------------------------------------------------------------------------- /src/TopoDS.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2005, by EADS CRC 19 | * (C) Copyright 2009, by EADS France 20 | */ 21 | 22 | SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) 23 | SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) 24 | 25 | %{ 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | %} 34 | 35 | /** 36 | * TopoDS_Shape 37 | */ 38 | // Ensure that the Java class will always be the good one, so we can use 39 | // instanceof operator. 40 | // Problem: Returning a shape require 2 initialisation (the TopoDS_Shape 41 | // and after the real TopoDS_XXXXX. It may reduce performance comparing 42 | // to libOccJava. 43 | 44 | %typemap(out) TopoDS_Shape 45 | { 46 | if($1.IsNull()) 47 | { 48 | $result=0L; //NULL 49 | } 50 | else 51 | { 52 | TopoDS_Shape * tsp=new TopoDS_Shape(); 53 | tsp->TShape($1.TShape()); 54 | tsp->Location($1.Location()); 55 | tsp->Orientation($1.Orientation()); 56 | $result=(jlong)tsp; 57 | } 58 | } 59 | 60 | %typemap(out) const TopoDS_Shape &, const TopoDS_Compound & 61 | { 62 | if($1->IsNull()) 63 | { 64 | $result=0L; //NULL 65 | } 66 | else 67 | { 68 | $1_basetype * tsp=new $1_basetype(); 69 | tsp->TShape($1->TShape()); 70 | tsp->Location($1->Location()); 71 | tsp->Orientation($1->Orientation()); 72 | $result=(jlong)tsp; 73 | } 74 | } 75 | 76 | %typemap(javaout) TopoDS_Shape*, TopoDS_Shape, const TopoDS_Shape&, const TopoDS_Compound & 77 | { 78 | long cPtr = $jnicall; 79 | return ($javaclassname)TopoDS_Shape.create(cPtr); 80 | } 81 | 82 | %typemap(javacode) TopoDS_Shape 83 | %{ 84 | private long myTShape; 85 | protected static TopoDS_Shape downcast(TopoDS_Shape in) 86 | { 87 | TopoDS_Shape toReturn = create(getCPtr(in)); 88 | in.swigCMemOwn=false; 89 | return toReturn; 90 | } 91 | 92 | protected static TopoDS_Shape create(long in) 93 | { 94 | if(in==0) 95 | return null; 96 | //second argument is not use in swig 97 | TopAbs_ShapeEnum type = TopAbs_ShapeEnum.swigToEnum(OccJavaJNI.TopoDS_Shape_shapeType(in, null)); 98 | return create(in, type); 99 | } 100 | 101 | protected static TopoDS_Shape create(long in, TopAbs_ShapeEnum type) 102 | { 103 | TopoDS_Shape toReturn=null; 104 | if(in==0) 105 | return null; 106 | switch(type) 107 | { 108 | case COMPOUND: 109 | toReturn=new TopoDS_Compound(in, true); 110 | break; 111 | case COMPSOLID: 112 | toReturn=new TopoDS_CompSolid(in, true); 113 | break; 114 | case SOLID: 115 | toReturn=new TopoDS_Solid(in, true); 116 | break; 117 | case SHELL: 118 | toReturn=new TopoDS_Shell(in, true); 119 | break; 120 | case FACE: 121 | toReturn=new TopoDS_Face(in, true); 122 | break; 123 | case WIRE: 124 | toReturn=new TopoDS_Wire(in, true); 125 | break; 126 | case EDGE: 127 | toReturn=new TopoDS_Edge(in, true); 128 | break; 129 | case VERTEX: 130 | toReturn=new TopoDS_Vertex(in, true); 131 | break; 132 | } 133 | toReturn.myTShape=toReturn.getTShape(); 134 | return toReturn; 135 | } 136 | public boolean isSame(TopoDS_Shape s) 137 | { 138 | /*if(myTShape==0) 139 | myTShape=getTShape(); 140 | 141 | if(s.myTShape==0) 142 | s.myTShape=s.getTShape(); 143 | 144 | if(myTShape==s.myTShape) 145 | { 146 | return nativeIsSame(s); 147 | } 148 | else return false;*/ 149 | return nativeIsSame(s); 150 | } 151 | 152 | /** 153 | * Alias on the isSame method for an easy use of this class in java 154 | * collections 155 | */ 156 | public boolean equals(Object o) 157 | { 158 | if (o instanceof TopoDS_Shape) 159 | { 160 | return nativeIsEqual((TopoDS_Shape)o); 161 | } 162 | else return false; 163 | } 164 | 165 | public int hashCode() 166 | { 167 | return hashCode(Integer.MAX_VALUE); 168 | } 169 | 170 | protected static TopoDS_Shape[] cArrayWrap(long[] ptrs) 171 | { 172 | TopoDS_Shape[] toReturn = new TopoDS_Shape[ptrs.length/2]; 173 | long ptr; 174 | int type; 175 | for (int i=0, j=0; iTShape(); 242 | } 243 | } 244 | 245 | class TopoDS_Compound: public TopoDS_Shape 246 | { 247 | }; 248 | 249 | class TopoDS_CompSolid: public TopoDS_Shape 250 | { 251 | }; 252 | 253 | class TopoDS_Solid: public TopoDS_Shape 254 | { 255 | }; 256 | 257 | class TopoDS_Shell: public TopoDS_Shape 258 | { 259 | }; 260 | 261 | class TopoDS_Face: public TopoDS_Shape 262 | { 263 | }; 264 | 265 | class TopoDS_Wire: public TopoDS_Shape 266 | { 267 | }; 268 | 269 | class TopoDS_Edge: public TopoDS_Shape 270 | { 271 | }; 272 | 273 | class TopoDS_Vertex: public TopoDS_Shape 274 | { 275 | }; 276 | 277 | class TopoDS_Iterator 278 | { 279 | %rename(initialize) Initialize; 280 | %rename(more) More; 281 | %rename(next) Next; 282 | %rename(value) Value; 283 | public: 284 | TopoDS_Iterator(); 285 | TopoDS_Iterator(const TopoDS_Shape& S, 286 | const Standard_Boolean cumOri = Standard_True, 287 | const Standard_Boolean cumLoc = Standard_True); 288 | void Initialize(const TopoDS_Shape& S, 289 | const Standard_Boolean cumOri = Standard_True, 290 | const Standard_Boolean cumLoc = Standard_True) ; 291 | Standard_Boolean More() const; 292 | void Next() ; 293 | const TopoDS_Shape& Value() const; 294 | }; 295 | 296 | class TopoDS_Builder 297 | { 298 | %rename(makeWire) MakeWire; 299 | %rename(makeCompound) MakeCompound; 300 | %rename(add) Add; 301 | %rename(remove) Remove; 302 | 303 | TopoDS_Builder()=0; 304 | public: 305 | void MakeWire(TopoDS_Wire& W) const; 306 | void MakeShell(TopoDS_Shell& S) const; 307 | void MakeSolid(TopoDS_Solid& S) const; 308 | void MakeCompSolid(TopoDS_CompSolid& C) const; 309 | void MakeCompound(TopoDS_Compound& C) const; 310 | void Add(TopoDS_Shape& S,const TopoDS_Shape& C) const; 311 | void Remove(TopoDS_Shape& S,const TopoDS_Shape& C) const; 312 | }; 313 | 314 | -------------------------------------------------------------------------------- /src/XSControl.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Info: http://jcae.sourceforge.net 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License as published by the Free 6 | * Software Foundation; either version 2.1 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | * details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software Foundation, Inc., 16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | * (C) Copyright 2007, by EADS France 19 | */ 20 | 21 | //A workaround for charset encoding problems 22 | %typemap(jni) jbyte[] "jbyteArray" 23 | %typemap(jtype) jbyte[] "byte[]" 24 | %typemap(jstype) jbyte[] "byte[]" 25 | %typemap(in) jbyte[] 26 | { 27 | int length = JCALL1(GetArrayLength, jenv, $input); 28 | jbyte * name = new jbyte[length+1]; 29 | JCALL4(GetByteArrayRegion, jenv, $input, 0, length, name); 30 | name[length] = '\0'; 31 | $1 = name; 32 | } 33 | %typemap(javain) jbyte[] "$javainput" 34 | 35 | 36 | /** 37 | * XSControl_Reader 38 | */ 39 | %{ 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | %} 53 | class XSControl_Reader 54 | { 55 | %javamethodmodifiers ReadFile(const Standard_CString filename)" 56 | /** 57 | * @deprecated May segfault if path name include none-ASCII caracters. Use 58 | * readFile(stringPath.getBytes()) instead. 59 | */ 60 | public"; 61 | 62 | XSControl_Reader()=0; 63 | %rename(readFile) ReadFile; 64 | %rename(transferRoots) TransferRoots; 65 | %rename(clearShapes) ClearShapes; 66 | %rename(nbRootsForTransfer) NbRootsForTransfer; 67 | %rename(oneShape) OneShape; 68 | public: 69 | IFSelect_ReturnStatus ReadFile(const Standard_CString filename); 70 | //IFSelect_ReturnStatus ReadFile(jbyte filename[]); 71 | Standard_Integer TransferRoots() ; 72 | void ClearShapes(); 73 | Standard_Integer NbRootsForTransfer(); 74 | TopoDS_Shape OneShape() const; 75 | }; 76 | 77 | %extend XSControl_Reader 78 | { 79 | //A workaround for charset encoding problems 80 | IFSelect_ReturnStatus readFile(jbyte filename[]) 81 | { 82 | return self->ReadFile((char*)filename); 83 | } 84 | }; 85 | 86 | class STEPControl_Reader: public XSControl_Reader 87 | { 88 | public: 89 | STEPControl_Reader(); 90 | }; 91 | 92 | %extend STEPControl_Reader 93 | { 94 | //dirty quick implementation of label step reading 95 | //find how to generalize this to IGES 96 | const char * getLabel(TopoDS_Shape * theShape) 97 | { 98 | const Handle(XSControl_WorkSession)& theSession = self->WS(); 99 | const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader(); 100 | Handle(Standard_Transient) anEntity = aReader->EntityFromShapeResult(*theShape, 1); 101 | if (anEntity.IsNull()) { 102 | // as just mapped 103 | anEntity = aReader->EntityFromShapeResult (*theShape,-1); 104 | } 105 | 106 | if (anEntity.IsNull()) { 107 | // as anything 108 | anEntity = aReader->EntityFromShapeResult (*theShape,4); 109 | } 110 | 111 | if (anEntity.IsNull()) { 112 | cout<<"Warning: XSInterface_STEPReader::ReadAttributes() entity not found"<Name()->ToCString(); 126 | } 127 | } 128 | }; 129 | 130 | class IGESControl_Reader: public XSControl_Reader 131 | { 132 | public: 133 | IGESControl_Reader(); 134 | }; 135 | 136 | %extend IGESControl_Reader 137 | { 138 | //dirty quick implementation of label iges reading 139 | const char * getLabel(TopoDS_Shape theShape) 140 | { 141 | const Handle(XSControl_WorkSession)& theSession = self->WS(); 142 | const Handle(Interface_InterfaceModel)& theModel = theSession->Model(); 143 | const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader(); 144 | const Handle(Transfer_TransientProcess)& tp = aReader->TransientProcess(); 145 | Standard_Integer nb = theModel->NbEntities(); 146 | for(Standard_Integer i=1; i<=nb; i++) 147 | { 148 | Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i)); 149 | 150 | if (ent.IsNull()) 151 | continue; 152 | 153 | Handle(Transfer_Binder) binder = tp->Find(ent); 154 | 155 | if (binder.IsNull()) 156 | continue; 157 | TopoDS_Shape oneShape = TransferBRep::ShapeResult(binder); 158 | if (oneShape.IsNull()) 159 | continue; 160 | if (oneShape.IsEqual(theShape)) 161 | { 162 | if (ent->HasName()) 163 | return ent->NameValue()->String().ToCString(); 164 | else 165 | return NULL; 166 | } 167 | } 168 | return NULL; 169 | } 170 | 171 | //get shape for label 172 | TopoDS_Shape getShape(char* shapeName) 173 | { 174 | const TCollection_AsciiString ascShapeName(shapeName); 175 | const Handle(XSControl_WorkSession)& theSession = self->WS(); 176 | const Handle(Interface_InterfaceModel)& theModel = theSession->Model(); 177 | const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader(); 178 | const Handle(Transfer_TransientProcess)& tp = aReader->TransientProcess(); 179 | Standard_Integer nb = theModel->NbEntities(); 180 | TopoDS_Shape retShape; 181 | for(Standard_Integer i=1; i<=nb; i++) 182 | { 183 | Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i)); 184 | 185 | if (ent.IsNull()) 186 | continue; 187 | Handle(Transfer_Binder) binder = tp->Find(ent); 188 | 189 | if (binder.IsNull()) 190 | continue; 191 | TopoDS_Shape oneShape = TransferBRep::ShapeResult(binder); 192 | 193 | if (oneShape.IsNull()) 194 | continue; 195 | 196 | if (ent->HasName() && ent->NameValue()->String().IsEqual(ascShapeName)) 197 | retShape = oneShape; 198 | } 199 | return retShape; 200 | } 201 | 202 | //dump all labels 203 | void dumpLabels() 204 | { 205 | const Handle(XSControl_WorkSession)& theSession = self->WS(); 206 | const Handle(Interface_InterfaceModel)& theModel = theSession->Model(); 207 | Standard_Integer nb = theModel->NbEntities(); 208 | for(Standard_Integer i=1; i<=nb; i++) 209 | { 210 | Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i)); 211 | if (ent.IsNull()) continue; 212 | if (ent->HasName()) 213 | { 214 | std::cout << ent->NameValue()->String().ToCString() << std::endl; 215 | } 216 | } 217 | } 218 | }; 219 | 220 | /** 221 | * STEPControl_Writer 222 | * Usage: 223 | * STEPControl_Writer aWriter = new STEPControl_Writer() 224 | * aWriter.transfer(shape, STEPControl_StepModelType.AsIs) 225 | * aWriter.write("foo.stp") 226 | */ 227 | %{ 228 | #include 229 | %} 230 | class STEPControl_Writer 231 | { 232 | %rename(write) Write; 233 | %rename(transfer) Transfer; 234 | %rename(model) Model; 235 | public: 236 | STEPControl_Writer(); 237 | IFSelect_ReturnStatus Write(const Standard_CString filename); 238 | IFSelect_ReturnStatus Transfer(TopoDS_Shape theShape, STEPControl_StepModelType mode); 239 | Handle_StepData_StepModel Model(const Standard_Boolean newone); 240 | }; 241 | 242 | 243 | %rename(AsIs) STEPControl_AsIs; 244 | %rename(ManifoldSolidBrep) STEPControl_ManifoldSolidBrep; 245 | %rename(BrepWithVoids) STEPControl_BrepWithVoids; 246 | %rename(FacetedBrep) STEPControl_FacetedBrep; 247 | %rename(FacetedBrepAndBrepWithVoids) STEPControl_FacetedBrepAndBrepWithVoids; 248 | %rename(ShellBasedSurfaceModel) STEPControl_ShellBasedSurfaceModel; 249 | %rename(GeometricCurveSet) STEPControl_GeometricCurveSet; 250 | %rename(Hybrid) STEPControl_Hybrid; 251 | enum STEPControl_StepModelType { 252 | STEPControl_AsIs, 253 | STEPControl_ManifoldSolidBrep, 254 | STEPControl_BrepWithVoids, 255 | STEPControl_FacetedBrep, 256 | STEPControl_FacetedBrepAndBrepWithVoids, 257 | STEPControl_ShellBasedSurfaceModel, 258 | STEPControl_GeometricCurveSet, 259 | STEPControl_Hybrid 260 | }; 261 | 262 | /** 263 | * IGESControl_Writer 264 | * Usage: 265 | * new IGESControl_Controller().init() 266 | * IGESControl_Writer aWriter = new IGESControl_Writer("MM", 0) 267 | * aWriter.addShape(shape) 268 | * aWriter.computeModel() 269 | * aWriter.write("foo.igs") 270 | */ 271 | %{ 272 | #include 273 | %} 274 | class IGESControl_Writer 275 | { 276 | %rename(write) Write; 277 | %rename(addShape) AddShape; 278 | %rename(computeModel) ComputeModel; 279 | public: 280 | IGESControl_Writer(); 281 | IGESControl_Writer(const Standard_CString unit, const Standard_Integer modecr = 0); 282 | Standard_Boolean Write(const Standard_CString filename); 283 | Standard_Boolean AddShape(const TopoDS_Shape& sh); 284 | void ComputeModel(); 285 | }; 286 | 287 | %{ 288 | #include 289 | %} 290 | class IGESControl_Controller 291 | { 292 | %rename(init) Init; 293 | public: 294 | IGESControl_Controller(); 295 | void Init(); 296 | }; 297 | 298 | 299 | -------------------------------------------------------------------------------- /src/jnistream.cxx: -------------------------------------------------------------------------------- 1 | #include "jnistream.hxx" 2 | 3 | //#define DEBUG 4 | using namespace std; 5 | 6 | static void jthrow(JNIEnv *env, const char *name, const char *msg) 7 | { 8 | jclass cls = env->FindClass(name); 9 | /* if cls is NULL, an exception has already been thrown => remove it because it's from the JVM*/ 10 | if (cls == NULL) 11 | { 12 | env->ExceptionClear(); 13 | jthrow(env,name,msg); 14 | } 15 | else 16 | { 17 | if(env->ThrowNew(cls, msg)<0) 18 | { 19 | //the throw exception failled 20 | std::cout<<"#JNI throw exception failled !"<DeleteLocalRef(cls); 25 | } 26 | } 27 | 28 | jnistreambuf::~jnistreambuf() 29 | { 30 | delete[] nativeBuffer; 31 | } 32 | 33 | jnistreambuf::jnistreambuf(JNIEnv * env, jobject jstream, int bufferSize): 34 | env(env), jstream(jstream) 35 | { 36 | #ifdef DEBUG 37 | cerr << "jnistreambuf::jnistreambuf [start]" << endl; 38 | #endif 39 | nativeBuffer = new char[bufferSize]; 40 | fullNioBuffer=env->NewDirectByteBuffer(nativeBuffer, bufferSize); 41 | 42 | jclass inputStreamClass = env->FindClass("java/nio/channels/ReadableByteChannel"); 43 | jclass outputStreamClass = env->FindClass("java/nio/channels/WritableByteChannel"); 44 | 45 | readMID = env->GetMethodID(inputStreamClass, "read","(Ljava/nio/ByteBuffer;)I"); 46 | writeMID = env->GetMethodID(outputStreamClass, "write","(Ljava/nio/ByteBuffer;)I"); 47 | 48 | bool in=env->IsInstanceOf(jstream, inputStreamClass)!=0; 49 | bool out=env->IsInstanceOf(jstream, outputStreamClass)!=0; 50 | 51 | if(in) 52 | { 53 | #ifdef DEBUG 54 | cerr << "jnistreambuf::jnistreambuf: init reading buffer" << endl; 55 | #endif 56 | setg(nativeBuffer, // beginning of putback area 57 | nativeBuffer, // read position 58 | nativeBuffer); // end position 59 | } 60 | 61 | if(out) 62 | { 63 | #ifdef DEBUG 64 | cerr << "jnistreambuf::jnistreambuf: init writting buffer [start]" << endl; 65 | #endif 66 | setp( nativeBuffer, nativeBuffer + bufferSize ); 67 | 68 | #ifdef DEBUG 69 | cerr << "jnistreambuf::jnistreambuf: init writting buffer [done]" << endl; 70 | #endif 71 | } 72 | 73 | if(!out && !in) 74 | { 75 | jthrow(env, "java/lang/ClassCastException", "InputStream or OutputStream expected"); 76 | } 77 | 78 | #ifdef DEBUG 79 | cerr << "jnistreambuf::jnistreambuf [done]" << endl; 80 | #endif 81 | } 82 | 83 | int jnistreambuf::underflow() 84 | { 85 | #ifdef DEBUG 86 | cerr << "jnistreambuf::underflow" << endl; 87 | #endif 88 | // used for input buffer only 89 | if ( gptr() && ( gptr() < egptr())) 90 | return * reinterpret_cast( gptr()); 91 | 92 | //read the java bytes 93 | int num = env->CallIntMethod(jstream, readMID, fullNioBuffer); 94 | 95 | if (num <= 0) // ERROR or EOF 96 | return EOF; 97 | 98 | // reset buffer pointers 99 | setg( eback(), // beginning of putback area 100 | eback(), // read position 101 | eback() + num); // end of buffer 102 | 103 | // return next character 104 | return * reinterpret_cast( gptr()); 105 | } 106 | 107 | int jnistreambuf::overflow( int c) 108 | { 109 | #ifdef DEBUG 110 | cerr << "jnistreambuf::overflow" << endl; 111 | #endif 112 | // used for output buffer only 113 | if (c != EOF) { 114 | *pptr() = c; 115 | pbump(1); 116 | } 117 | 118 | if ( flush_buffer() == EOF) 119 | return EOF; 120 | return c; 121 | } 122 | 123 | int jnistreambuf::sync() 124 | { 125 | #ifdef DEBUG 126 | cerr << "jnistreambuf::sync()" << endl; 127 | #endif 128 | // Changed to use flush_buffer() instead of overflow( EOF) 129 | // which caused improper behavior with std::endl and flush(), 130 | // bug reported by Vincent Ricard. 131 | if ( pptr() && pptr() > pbase()) { 132 | if ( flush_buffer() == EOF) 133 | return -1; 134 | } 135 | return 0; 136 | } 137 | 138 | int jnistreambuf::flush_buffer() 139 | { 140 | #ifdef DEBUG 141 | cerr << "jnistreambuf::flush_buffer" << endl; 142 | //for(char * p=pbase(); p!=pptr(); p++) cerr << *p; 143 | #endif 144 | // Separate the writing of the buffer from overflow() and 145 | // sync() operation. 146 | int w = pptr() - pbase(); 147 | 148 | //write the c chars 149 | jobject nioBuffer; 150 | 151 | if(pptr()==epptr()) 152 | nioBuffer=fullNioBuffer; 153 | else 154 | nioBuffer=env->NewDirectByteBuffer(pbase(), w); 155 | 156 | env->CallIntMethod(jstream, writeMID, nioBuffer); 157 | 158 | pbump( -w); 159 | return w; 160 | } 161 | 162 | -------------------------------------------------------------------------------- /src/jnistream.hxx: -------------------------------------------------------------------------------- 1 | #ifndef JNISTREAM_H 2 | #define JNISTREAM_H 3 | 4 | // standard C++ with new header file names and std:: namespace 5 | #include 6 | #include 7 | 8 | class jnistreambuf : public std::streambuf 9 | { 10 | public: 11 | jnistreambuf(JNIEnv * env, jobject stream, int bufferSize = 1024); 12 | virtual int overflow( int c = EOF); 13 | virtual int underflow(); 14 | virtual int sync(); 15 | ~jnistreambuf(); 16 | private: 17 | int flush_buffer(); 18 | char * nativeBuffer; 19 | JNIEnv * env; 20 | jmethodID readMID, writeMID; 21 | jobject jstream, fullNioBuffer; 22 | }; 23 | 24 | #endif 25 | --------------------------------------------------------------------------------