|
| 1 | +GEOMLib - 3D CSG Geometry Library for MATLAB® and GNU Octave |
| 2 | +============================================================ |
| 3 | + |
| 4 | +**GEOMLib** is a 2D and 3D geometry library for MATLAB® and GNU Octave |
| 5 | +allowing _mesh based_ CSG (Composite Solid Geometry) operations. |
| 6 | + |
| 7 | +Originally developed for use with the [FEATool Multiphysics](https://www.featool.com) |
| 8 | +FEA simulation toolbox, but now replaced with the OpenCASCADE geometry |
| 9 | +kernel to support BREP CAD geometry support. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +Installation |
| 15 | +------------ |
| 16 | + |
| 17 | +Download and copy the library to a folder. Start MATLAB® or Octave and |
| 18 | +start the `runtests` script (or `runtests 1` for verbose output) to |
| 19 | +run the test and validation suite. |
| 20 | + |
| 21 | + |
| 22 | +Examples |
| 23 | +-------- |
| 24 | + |
| 25 | +1. 2D example of the union of a circle and unit square |
| 26 | + |
| 27 | + % Create circle |
| 28 | + c1 = gobj_circle([0, 0], 0.5, 'C1'); |
| 29 | + c1 = convert_gobj_polygons( c1, 1 ); |
| 30 | + c1 = csg_op( c1, 'b' ); |
| 31 | + |
| 32 | + % Create unit square |
| 33 | + r1 = gobj_rectangle(0, 1, 0, 1, 'R1'); |
| 34 | + r1 = convert_gobj_polygons( r1, 2 ); |
| 35 | + r1 = csg_op( r1, 'b' ); |
| 36 | + |
| 37 | + % Join circle and square |
| 38 | + [res,~,stat] = csg_op( c1, r1, '+' ); |
| 39 | + |
| 40 | + % Visualize result |
| 41 | + csg_op(res, 'v') |
| 42 | + |
| 43 | +2. 3D subtraction of a sphere from a unit cube |
| 44 | + |
| 45 | + % Create sphere |
| 46 | + s1 = gobj_sphere([0, 0, 1], 0.5, 'S1'); |
| 47 | + s1 = convert_gobj_polygons( s1, 1 ); |
| 48 | + s1 = csg_op( s1, 'b' ); |
| 49 | + |
| 50 | + % Create unit cube |
| 51 | + b1 = gobj_block(0, 1, 0, 1, 0, 1, 'B1'); |
| 52 | + b1 = convert_gobj_polygons( b1, 2 ); |
| 53 | + b1 = csg_op( b1, 'b' ); |
| 54 | + |
| 55 | + % Subtracting sphere from cube |
| 56 | + [res,~,stat] = csg_op( b1, s1, '-' ); |
| 57 | + |
| 58 | + % Visualize result |
| 59 | + csg_op(res, 'v') |
| 60 | + |
| 61 | +3. For more examples see the tests in the _test_ directory. |
| 62 | + |
| 63 | + |
| 64 | +Functions |
| 65 | +--------- |
| 66 | + |
| 67 | + % Main CSG functions: |
| 68 | + |
| 69 | + csg_op - apply CSG operation on polygons |
| 70 | + csg_polygon_recombination - recombine and tessellate polygons |
| 71 | + csg_polygon_tesselation - recombine and tessellate polygons |
| 72 | + |
| 73 | + % Geometry object primitives: |
| 74 | + |
| 75 | + gobj_block - create block |
| 76 | + gobj_circle - create circle |
| 77 | + gobj_cylinder - create cylinder |
| 78 | + gobj_ellipse - create ellipse |
| 79 | + gobj_polygon - create polygon |
| 80 | + gobj_rectangle - create rectangle |
| 81 | + gobj_sphere - create sphere |
| 82 | + |
| 83 | + % Geometry utility and help functions: |
| 84 | + |
| 85 | + convert_gobj_polygons - extract polygons from geometry object |
| 86 | + deduplicate - remove duplicate rows or columns within tolerance |
| 87 | + uunique - unsorted set unique |
| 88 | + |
| 89 | + |
| 90 | +Support |
| 91 | +------- |
| 92 | + |
| 93 | +This library has been open sourced on an _as is_ basis under the |
| 94 | +AGPLv3 License (see included LICENSE file) without warranty or |
| 95 | +support. |
| 96 | + |
| 97 | +For technical support, consulting, and custom development of this |
| 98 | +library, commercial licensing, or use of the newer OpenCASCADE based |
| 99 | +geometry library (allowing BREP CAD geometry modeling such as STEP and |
| 100 | +IGES formats) please [contact Precise |
| 101 | +Simulation](https://www.precisesimulation.com#contact) directly. |
| 102 | + |
| 103 | + |
| 104 | +License |
| 105 | +------- |
| 106 | + |
| 107 | +Copyright (C) 2013-2022 Precise Simulation Ltd. |
| 108 | + |
| 109 | +Keywords: Geometry, CSG, Mesh, MATLAB®, Octave |
| 110 | + |
| 111 | +This program is free software; you can redistribute it and/or modify |
| 112 | +it under the terms of version 3 of the GNU Affero General Public |
| 113 | +License (AGPLv3) as published by the Free Software Foundation. |
| 114 | + |
| 115 | +This program is distributed in the hope that it will be useful, but |
| 116 | +WITHOUT ANY WARRANTY; without even the implied warranty of |
| 117 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 118 | +General Public License for more details. |
| 119 | + |
| 120 | +You should have received a copy of the GNU Affero General Public |
| 121 | +License along with this program. If not, see |
| 122 | +[http://www.gnu.org/licenses](http://www.gnu.org/licenses). |
| 123 | + |
| 124 | + |
| 125 | +Trademarks |
| 126 | +---------- |
| 127 | + |
| 128 | +FEATool Multiphysics™ is a trademark of Precise Simulation |
| 129 | +Limited. MATLAB® is a registered trademark of The MathWorks, Inc. All |
| 130 | +other trademarks are the property of their respective owners. Precise |
| 131 | +Simulation and its products are not affiliated with, endorsed, or |
| 132 | +sponsored by these trademark owners. |
0 commit comments