| 1 | /* Matrix_and_Polygon.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2005,2011,2012,2015-2018,2020 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "Matrix_and_Polygon.h"cxx . . $ `<file>/fon/Matrix_and_Polygon.h`/ |
| 20 | |
| 21 | autoPolygoncxx . . $ autoPolygon# Matrix_to_Polygoncxx . . $ Matrix_to_Polygon(6b69e36d03ad103e). (Matrixcxx . . $ Matrix# me) { |
| 22 | try { |
| 23 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! nx == 2 || mycxx . . $ `melder/melder.h:44:9`! ny == 2, |
| 24 | U"The Matrix should have exactly 2 rows or columns."); |
| 25 | autoPolygoncxx . . $ autoPolygon# theecxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 26 | if (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny. == 2) { |
| 27 | /* |
| 28 | The matrix has two rows. |
| 29 | The first row will be interpreted as x values, the second as y values. |
| 30 | */ |
| 31 | thee =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Polygon_createcxx . . $ Polygon_create(2216cf3dda2361cc). (mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.); |
| 32 | thycxx . . $ `melder/melder.h:45:9`! xcxx . . $ structPolygon#x..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1); |
| 33 | thycxx . . $ `melder/melder.h:45:9`! ycxx . . $ structPolygon#y..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (2); |
| 34 | } else { |
| 35 | /* |
| 36 | The matrix has two columns. |
| 37 | The first column will be interpreted as x values, the second as y values. |
| 38 | */ |
| 39 | thee =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Polygon_createcxx . . $ Polygon_create(2216cf3dda2361cc). (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.); |
| 40 | thycxx . . $ `melder/melder.h:45:9`! xcxx . . $ structPolygon#x..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (1); |
| 41 | thycxx . . $ `melder/melder.h:45:9`! ycxx . . $ structPolygon#y..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (2); |
| 42 | } |
| 43 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 44 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 45 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Polygon."); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | autoMatrixcxx . . $ autoMatrix# Polygon_to_Matrixcxx . . $ Polygon_to_Matrix(56c41e1a1508d47f). (Polygoncxx . . $ Polygon# me) { |
| 50 | try { |
| 51 | /* |
| 52 | The matrix will have two rows: |
| 53 | the first column will represent x, the second will represent y. |
| 54 | */ |
| 55 | autoMatrixcxx . . $ autoMatrix# thee = Matrix_createcxx . . $ Matrix_create(494a3ae9ff7e3b60). (1.0, mycxx . . $ `melder/melder.h:44:9`! numberOfPointscxx . . $ structPolygon#numberOfPoints., mycxx . . $ `melder/melder.h:44:9`! numberOfPointscxx . . $ structPolygon#numberOfPoints., 1.0, 1.0, 1.0, 2.0, 2, 1.0, 1.0); |
| 56 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! xcxx . . $ structPolygon#x..getcxx . . $ autovector#get(e8d1da7fe68a6585).(); |
| 57 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (2) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! ycxx . . $ structPolygon#y..getcxx . . $ autovector#get(e8d1da7fe68a6585).(); |
| 58 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 59 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 60 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Matrix."); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /* End of file Matrix_and_Polygon.cpp */ |