├── History ├── INFO ├── LICENSE ├── Makefile ├── README.md ├── bin ├── Makefile ├── poland.xyz ├── wafer.xyz └── wafer2.xyz ├── fws ├── contour.fl └── readme ├── img ├── contour.xpm ├── data.xpm └── submesh.xpm ├── include ├── fl_contour.h ├── fl_gl_contour.h ├── fl_palette.h ├── geometry.h └── msmvtl │ ├── README │ ├── libdef.h │ ├── tmatrix │ ├── tmatrix.h │ ├── tmmanip.h │ ├── tmmath.h │ ├── tvector │ ├── tvector.h │ └── tvmath.h ├── makeinclude ├── obj └── Makefile ├── src ├── Makefile ├── fl_contour.cxx ├── fl_gl_contour.cxx └── fl_palette.cxx └── test ├── Makefile ├── contour.cxx └── contour.h /History: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | - 10/01/2003 3 | first Release of Fltk_Contour 4 | 5 | - 11/01/2003 6 | lineal and nearest Improved 7 | 8 | Fixed bugs in colormap. 9 | 10 | - 25/04/2004 11 | OpenGl widget is totaly independent library 12 | 13 | - 16/11/2004 14 | The Fl_2D_Gl_Contour widget was proted to Linux. 15 | 16 | - 13/01/2005 17 | The Fl_2D_Gl_Contour widget, The Fl_3D_Gl_Contour widget. 18 | the demos running on Linux. 19 | 20 | - 20/08/2006 21 | code completely rewriten. 22 | working on optimization methods. 23 | 24 | - 23/08/2006 25 | the nearest neighbor interpolation improved. 26 | 27 | - 04/09/2006 28 | input data files comments supported 29 | color palettes supported. 30 | 31 | - 06/09/2006 32 | Fixed some problem loading input files. 33 | 34 | - 11/01/2007 35 | Just one class Fl_Gl_Contour for all. 36 | Horrible bug removed. 37 | Optimized code. 38 | 39 | - 02/02/2007 40 | graphics 2D and 3D are independent 41 | Submesh cuting and saving 42 | 43 | - 25/09/2007 44 | 45 | some bugs fixed 46 | 47 | - 20/03/2008 48 | 49 | improved interface 50 | load and save file chooser 51 | improved submesh cutting 52 | 53 | - 12/06/2009 54 | 55 | bugs fixed 56 | 57 | - 26/11/2011 58 | 59 | bug fixed in function eval_centroide of src/fl_contour.cxx 60 | -------------------------------------------------------------------------------- /INFO: -------------------------------------------------------------------------------- 1 | // ======================================================================== 2 | // fl_contour 5.3.1 3 | // 4 | // Copyrigth 2002 by Edmanuel Torres (eetorres@gmail.com) 5 | // 6 | // This widget is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Library General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 2 of the License, or (at your option) any later version 10 | // or much better FLTK license, wich allow you static linking. 11 | // 12 | // This library is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // Library General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU Library General Public 18 | // License along with this library; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | // USA. 21 | // 22 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 23 | // me for any question, I will be very grateful with your feedbacks. 24 | // Get the last version at http://eetorres.googlepages.com/fltk_en 25 | // 26 | //======================================================================== 27 | // 28 | // type: $ tar -xvzf fltk_contour_x.x.x.tar.gz 29 | // type: $ cd fltk_countour 30 | // type: $ make 31 | // 32 | // you will find a test program in the bin subdirectory 33 | // to run it just type ./contour in the comand line and 34 | // 35 | // Enjoy it... 36 | // Edmanuel Torres 37 | // eetorres@gmail.com 38 | // ======================================================================== 39 | // NOTE: The input data is in XYZ plain text format. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # ======================================================================== 2 | # fl_contour 2.1 3 | # fl_gl_contour 1.9 4 | # geometry 0.7 5 | # 6 | # Copyrigth 2002 by Edmanuel Torres A. (eetorres@gmail.com) 7 | # 8 | # This widget is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU Library General Public 10 | # License as published by the Free Software Foundation; either 11 | # version 2 of the License, or (at your option) any later version 12 | # or much better FLTK license, wich allow you static linking. 13 | # 14 | # This library is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | # Library General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU Library General Public 20 | # License along with this library; if not, write to the Free Software 21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | # USA. 23 | # 24 | # Sent me suggestions, modifications or bugs. Don't hesitate to contact 25 | # me for any question, I will be very grateful with your feedbacks. 26 | # Get the last version at http:#eetorres.googlepages.com/fltk_en 27 | # 28 | #======================================================================== 29 | 30 | include makeinclude 31 | 32 | all: makeinclude 33 | for dir in $(DIRS); do\ 34 | echo "==== Compiling in $$dir ====";\ 35 | (cd $$dir; make || break);\ 36 | done 37 | 38 | clean: makeinclude 39 | for dir in $(DIRS); do\ 40 | echo "==== Cleaning in $$dir ====";\ 41 | (cd $$dir; make clean || break);\ 42 | done 43 | 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fltk_contour 2 | 2D and 3D contour and colour map of regular or scattered data in C++ 3 | 4 | An easy scientific data visualization widget for the FLTK library. The widget is an OpenGL based contour visualizer for Linux, which allow you to built 2D and 3D graph of contour and colour map for a xy regular or scattered data set. There is a good example with the topographic data of Poland with 5902 data points to introduce yourself how to use it. There is not much documentation but it is easy to use. The input data are in XYZ format, where Z is a function of XY of the form Z=F(X,Y). The data file is in plain text format. 5 | 6 | More information: 7 | 8 | https://sites.google.com/site/eetorres/contour 9 | -------------------------------------------------------------------------------- /bin/Makefile: -------------------------------------------------------------------------------- 1 | # Edmanuel Torres 21/10/2004 2 | 3 | include ../makeinclude 4 | 5 | clean: 6 | rm -rf *o $(PRGS) -------------------------------------------------------------------------------- /bin/wafer.xyz: -------------------------------------------------------------------------------- 1 | ~ Test file for the Fltk_Contour 2 | ~ Temperature sampling on a silicon wafer surface 3 | 5.5292E+001 -1.3296E+002 1.1909E+002 4 | -5.4868E+001 -1.3314E+002 1.1907E+002 5 | 2.8798E+001 -6.9251E+001 1.1891E+002 6 | -2.8577E+001 -6.9342E+001 1.1882E+002 7 | 1.3309E+002 -5.4974E+001 1.1817E+002 8 | -1.3292E+002 -5.5398E+001 1.1891E+002 9 | 6.9320E+001 -2.8632E+001 1.1909E+002 10 | -6.9228E+001 -2.8853E+001 1.1886E+002 11 | 0.0000E+000 0.0000E+000 1.1888E+002 12 | 6.9274E+001 2.8743E+001 1.1907E+002 13 | -6.9365E+001 2.8522E+001 1.1886E+002 14 | 1.3301E+002 5.5186E+001 1.1917E+002 15 | -1.3318E+002 5.4762E+001 1.1889E+002 16 | 2.8687E+001 6.9297E+001 1.1897E+002 17 | -2.8908E+001 6.9205E+001 1.1883E+002 18 | 5.5080E+001 1.3305E+002 1.1906E+002 19 | -5.5503E+001 1.3287E+002 1.1923E+002 20 | 0.0000E+000 0.0000E+000 1.1888E+002 21 | 1.0000E+002 0.0000E+000 1.1902E+002 22 | 0.0000E+000 0.0000E+000 1.1888E+002 23 | 8.6603E+001 5.0000E+001 1.1910E+002 24 | 0.0000E+000 0.0000E+000 1.1888E+002 25 | 5.0000E+001 8.6603E+001 1.1903E+002 26 | 0.0000E+000 0.0000E+000 1.1888E+002 27 | 6.1230E-015 1.0000E+002 1.1908E+002 28 | 0.0000E+000 0.0000E+000 1.1888E+002 29 | -5.0000E+001 8.6603E+001 1.1901E+002 30 | 0.0000E+000 0.0000E+000 1.1888E+002 31 | -8.6603E+001 5.0000E+001 1.1892E+002 32 | 0.0000E+000 0.0000E+000 1.1888E+002 33 | -1.0000E+002 1.2246E-014 1.1888E+002 34 | 0.0000E+000 0.0000E+000 1.1888E+002 35 | -8.6603E+001 -5.0000E+001 1.1890E+002 36 | 0.0000E+000 0.0000E+000 1.1888E+002 37 | -5.0000E+001 -8.6603E+001 1.1894E+002 38 | 0.0000E+000 0.0000E+000 1.1888E+002 39 | -1.8369E-014 -1.0000E+002 1.1899E+002 40 | 0.0000E+000 0.0000E+000 1.1888E+002 41 | 5.0000E+001 -8.6603E+001 1.1887E+002 42 | 0.0000E+000 0.0000E+000 1.1888E+002 43 | 8.6603E+001 -5.0000E+001 1.1865E+002 44 | 0.0000E+000 0.0000E+000 1.1888E+002 45 | 1.0000E+002 -2.4492E-014 1.1902E+002 46 | -------------------------------------------------------------------------------- /bin/wafer2.xyz: -------------------------------------------------------------------------------- 1 | -66.612500 -119.830500 118.511535 2 | -53.299000 -119.830500 118.502863 3 | -53.299000 -106.521000 118.466447 4 | -66.612500 -106.521000 118.475278 5 | 53.209000 119.740500 118.521737 6 | -39.985500 -119.830500 118.506121 7 | -39.985500 -106.521000 118.468600 8 | 66.522500 119.740500 118.545320 9 | 39.895500 106.431000 118.522667 10 | -26.672000 -119.830500 118.509017 11 | -26.672000 -106.521000 118.471858 12 | 26.582000 119.740500 118.547785 13 | 26.582000 106.431000 118.533363 14 | -13.358500 -119.830500 118.511493 15 | -13.358500 -106.521000 118.475115 16 | 13.268500 106.431000 118.544059 17 | -0.045000 106.431000 118.562688 18 | -0.045000 -119.830500 118.513969 19 | -0.045000 -106.521000 118.477741 20 | -13.358500 106.431000 118.579042 21 | -53.299000 119.740500 118.637648 22 | 13.268500 -119.830500 118.516446 23 | 13.268500 -106.521000 118.477234 24 | -39.985500 119.740500 118.639272 25 | 66.522500 106.431000 118.539422 26 | 26.582000 -119.830500 118.518922 27 | 26.582000 -106.521000 118.462657 28 | 79.836000 106.431000 118.564109 29 | 53.209000 93.121500 118.508839 30 | 39.895500 -119.830500 118.512907 31 | 39.895500 -106.521000 118.448080 32 | 53.209000 106.431000 118.514736 33 | 39.895500 93.121500 118.512901 34 | 53.209000 -119.830500 118.498330 35 | 53.209000 -106.521000 118.433465 36 | 26.582000 93.121500 118.523597 37 | -66.612500 106.431000 118.599923 38 | 66.522500 -119.830500 118.424663 39 | 66.522500 -106.521000 118.406667 40 | -26.672000 106.431000 118.577417 41 | -79.926000 -106.521000 118.484110 42 | 39.895500 119.740500 118.532433 43 | -66.612500 -93.211500 118.439022 44 | -79.926000 -93.211500 118.447854 45 | -39.985500 93.121500 118.512312 46 | 66.522500 93.121500 118.533525 47 | -53.299000 -93.211500 118.430191 48 | -53.299000 93.121500 118.516174 49 | 13.268500 93.121500 118.524991 50 | -79.926000 106.431000 118.586761 51 | -39.985500 -93.211500 118.431080 52 | 79.836000 79.812000 118.552314 53 | -26.672000 119.740500 118.629823 54 | -0.045000 119.740500 118.588804 55 | -26.672000 -93.211500 118.434337 56 | 53.209000 79.812000 118.506428 57 | 13.268500 119.740500 118.568295 58 | 26.582000 79.812000 118.477260 59 | -13.358500 -93.211500 118.426909 60 | -66.612500 119.740500 118.644773 61 | -13.358500 119.740500 118.609314 62 | -39.985500 106.431000 118.575792 63 | -0.045000 -93.211500 118.432253 64 | -13.358500 79.812000 118.399651 65 | -53.299000 106.431000 118.576213 66 | 79.836000 93.121500 118.558212 67 | 13.268500 -93.211500 118.426628 68 | -26.672000 79.812000 118.394106 69 | -79.926000 93.121500 118.541911 70 | -93.239500 93.121500 118.528749 71 | 26.582000 -93.211500 118.397829 72 | -66.612500 93.121500 118.543495 73 | 79.836000 66.502500 118.553521 74 | -0.045000 79.812000 118.431889 75 | 39.895500 -93.211500 118.383252 76 | 66.522500 79.812000 118.528061 77 | -26.672000 93.121500 118.513937 78 | -0.045000 93.121500 118.509685 79 | 53.209000 -93.211500 118.368576 80 | 39.895500 66.502500 118.469246 81 | -13.358500 93.121500 118.501307 82 | 66.522500 66.502500 118.531889 83 | 66.522500 -93.211500 118.353464 84 | -0.045000 66.502500 118.369355 85 | 13.268500 79.812000 118.464127 86 | 79.836000 -106.521000 118.267273 87 | 79.836000 -93.211500 118.249277 88 | -39.985500 66.502500 118.323213 89 | -93.239500 -93.211500 118.456685 90 | -66.612500 66.502500 118.418141 91 | -79.926000 -79.902000 118.411597 92 | -93.239500 -79.902000 118.420429 93 | -53.299000 79.812000 118.450853 94 | 26.582000 66.502500 118.434066 95 | -66.612500 -79.902000 118.403463 96 | -106.553000 79.812000 118.470737 97 | 79.836000 53.193000 118.557350 98 | -66.612500 79.812000 118.483457 99 | -53.299000 -79.902000 118.401185 100 | -39.985500 79.812000 118.407895 101 | 66.522500 53.193000 118.532972 102 | -53.299000 66.502500 118.370677 103 | -39.985500 -79.902000 118.362315 104 | 39.895500 53.193000 118.466649 105 | 39.895500 79.812000 118.476549 106 | -13.358500 66.502500 118.336999 107 | -26.672000 -79.902000 118.353695 108 | -0.045000 53.193000 118.365459 109 | -79.926000 79.812000 118.497061 110 | 13.268500 66.502500 118.401711 111 | -13.358500 -79.902000 118.357022 112 | -39.985500 53.193000 118.311756 113 | -26.672000 66.502500 118.304643 114 | 26.582000 53.193000 118.431223 115 | -0.045000 -79.902000 118.377992 116 | -79.926000 53.193000 118.385430 117 | -93.239500 79.812000 118.483899 118 | -93.239500 66.502500 118.439049 119 | 13.268500 -79.902000 118.398962 120 | 13.268500 53.193000 118.397815 121 | -79.926000 66.502500 118.450740 122 | 53.209000 53.193000 118.502047 123 | 26.582000 -79.902000 118.390071 124 | 39.895500 39.883500 118.464024 125 | 66.522500 39.883500 118.534055 126 | 53.209000 66.502500 118.504629 127 | 39.895500 -79.902000 118.359805 128 | -0.045000 39.883500 118.361564 129 | -13.358500 53.193000 118.333104 130 | -119.866500 66.502500 118.412725 131 | 53.209000 -79.902000 118.312793 132 | -39.985500 39.883500 118.321431 133 | -106.553000 66.502500 118.425887 134 | -26.672000 53.193000 118.311616 135 | 66.522500 -79.902000 118.288576 136 | 13.268500 39.883500 118.393920 137 | -79.926000 39.883500 118.364425 138 | -66.612500 53.193000 118.354605 139 | 79.836000 -79.902000 118.231282 140 | -106.553000 39.883500 118.369727 141 | -106.553000 53.193000 118.381037 142 | -13.358500 39.883500 118.329208 143 | -106.553000 -79.902000 118.429260 144 | 79.836000 26.574000 118.534791 145 | -93.239500 -66.592500 118.389974 146 | -106.553000 -66.592500 118.393004 147 | 39.895500 26.574000 118.461399 148 | 53.209000 39.883500 118.499450 149 | -79.926000 -66.592500 118.388919 150 | -26.672000 39.883500 118.321290 151 | -93.239500 53.193000 118.394199 152 | 26.582000 39.883500 118.428598 153 | -66.612500 -66.592500 118.386643 154 | -26.672000 26.574000 118.330965 155 | -66.612500 39.883500 118.338414 156 | -119.866500 53.193000 118.368448 157 | -53.299000 -66.592500 118.370384 158 | -66.612500 26.574000 118.330793 159 | -53.299000 39.883500 118.321572 160 | -53.299000 53.193000 118.328446 161 | -39.985500 -66.592500 118.323300 162 | -93.239500 39.883500 118.379133 163 | -53.299000 26.574000 118.331246 164 | 66.522500 26.574000 118.532809 165 | -26.672000 -66.592500 118.293590 166 | 66.522500 13.264500 118.537418 167 | 26.582000 26.574000 118.425973 168 | -39.985500 26.574000 118.331106 169 | -13.358500 -66.592500 118.314469 170 | 26.582000 13.264500 118.423348 171 | -13.358500 13.264500 118.340499 172 | -119.866500 39.883500 118.360320 173 | -0.045000 -66.592500 118.335348 174 | -79.926000 26.574000 118.347136 175 | 79.836000 39.883500 118.555465 176 | -66.612500 13.264500 118.330784 177 | 13.268500 -66.592500 118.356228 178 | -0.045000 26.574000 118.357668 179 | -119.866500 26.574000 118.357125 180 | 13.268500 26.574000 118.390547 181 | 26.582000 -66.592500 118.377107 182 | 53.209000 13.264500 118.498990 183 | -106.553000 13.264500 118.353471 184 | 79.836000 13.264500 118.524773 185 | 39.895500 -66.592500 118.332437 186 | -119.866500 13.264500 118.359560 187 | 53.209000 26.574000 118.496825 188 | 13.268500 13.264500 118.387922 189 | 53.209000 -66.592500 118.282610 190 | 39.895500 13.264500 118.460561 191 | -106.553000 26.574000 118.361599 192 | -13.358500 26.574000 118.330824 193 | 66.522500 -66.592500 118.232782 194 | 13.268500 -0.045000 118.388314 195 | 66.522500 -0.045000 118.542026 196 | -0.045000 13.264500 118.353773 197 | 79.836000 -66.592500 118.208575 198 | -26.672000 -0.045000 118.342302 199 | -66.612500 -0.045000 118.330775 200 | -79.926000 13.264500 118.336903 201 | -119.866500 -66.592500 118.401836 202 | -93.239500 26.574000 118.371005 203 | -106.553000 -53.283000 118.375430 204 | -119.866500 -53.283000 118.376918 205 | -53.299000 13.264500 118.334626 206 | -0.045000 -0.045000 118.349963 207 | -93.239500 -53.283000 118.374374 208 | -106.553000 -0.045000 118.353962 209 | 66.522500 -13.354500 118.546635 210 | 39.895500 -0.045000 118.465170 211 | -79.926000 -53.283000 118.372100 212 | 26.582000 -0.045000 118.426742 213 | -26.672000 13.264500 118.340640 214 | -93.239500 13.264500 118.354641 215 | -66.612500 -53.283000 118.366262 216 | 26.582000 -13.354500 118.428158 217 | 53.209000 -0.045000 118.503598 218 | -53.299000 -0.045000 118.334617 219 | -53.299000 -53.283000 118.336275 220 | -13.358500 -13.354500 118.339125 221 | -13.358500 -0.045000 118.346145 222 | -39.985500 -0.045000 118.338460 223 | -39.985500 -53.283000 118.305457 224 | -53.299000 -13.354500 118.334608 225 | -39.985500 13.264500 118.338469 226 | 79.836000 -13.354500 118.534093 227 | -26.672000 -53.283000 118.304304 228 | -93.239500 -13.354500 118.350986 229 | 79.836000 -0.045000 118.529433 230 | -93.239500 -0.045000 118.345596 231 | -13.358500 -53.283000 118.317383 232 | 53.209000 -13.354500 118.508207 233 | -79.926000 -0.045000 118.336924 234 | 79.836000 -26.664000 118.452191 235 | -0.045000 -53.283000 118.338262 236 | 13.268500 -13.354500 118.382338 237 | 13.268500 -26.664000 118.369055 238 | 39.895500 -13.354500 118.469779 239 | 13.268500 -53.283000 118.359142 240 | -26.672000 -13.354500 118.340278 241 | -26.672000 -26.664000 118.328287 242 | 53.209000 -26.664000 118.506516 243 | 26.582000 -53.283000 118.388309 244 | -66.612500 -13.354500 118.330766 245 | -79.926000 -13.354500 118.336945 246 | -39.985500 -13.354500 118.338450 247 | 39.895500 -53.283000 118.434130 248 | -106.553000 -13.354500 118.357005 249 | -0.045000 -26.664000 118.344091 250 | 39.895500 -26.664000 118.460695 251 | 53.209000 -53.283000 118.374890 252 | 79.836000 -39.973500 118.310012 253 | -66.612500 -26.664000 118.330756 254 | 26.582000 -26.664000 118.414875 255 | 66.522500 -53.283000 118.255790 256 | 39.895500 -39.973500 118.447413 257 | -0.045000 -13.354500 118.347005 258 | -106.553000 -26.664000 118.362914 259 | 79.836000 -53.283000 118.152772 260 | -0.045000 -39.973500 118.341177 261 | -13.358500 -26.664000 118.327134 262 | -39.985500 -39.973500 118.317448 263 | -39.985500 -26.664000 118.329440 264 | -119.866500 -0.045000 118.361995 265 | -106.553000 -39.973500 118.368823 266 | -119.866500 -39.973500 118.371009 267 | 66.522500 -26.664000 118.551244 268 | -79.926000 -26.664000 118.342966 269 | -93.239500 -39.973500 118.366638 270 | -53.299000 -39.973500 118.318601 271 | -119.866500 -26.664000 118.366866 272 | -53.299000 -26.664000 118.330593 273 | -79.926000 -39.973500 118.353172 274 | 53.209000 -39.973500 118.493233 275 | 26.582000 -39.973500 118.401592 276 | -93.239500 -26.664000 118.360729 277 | -66.612500 -39.973500 118.345882 278 | -13.358500 -39.973500 118.320297 279 | 13.268500 -39.973500 118.362056 280 | 66.522500 -39.973500 118.433550 281 | -26.672000 -39.973500 118.316295 282 | -119.866500 -13.354500 118.364431 283 | -------------------------------------------------------------------------------- /fws/contour.fl: -------------------------------------------------------------------------------- 1 | # data file for the Fltk User Interface Designer (fluid) 2 | version 1.0300 3 | header_name {../test/contour.h} 4 | code_name {../test/contour.cxx} 5 | decl {\#include } {public local 6 | } 7 | 8 | decl {TMatrix d;} {private local 9 | } 10 | 11 | decl {const char * f;} {private local 12 | } 13 | 14 | decl {char file_[128];} {private local 15 | } 16 | 17 | decl {char file_name_[32];} {private local 18 | } 19 | 20 | decl {char submesh_file_[128];} {private local 21 | } 22 | 23 | decl {char submesh_file_name_[32];} {private local 24 | } 25 | 26 | decl {char directory_[128];} {private local 27 | } 28 | 29 | Function {} {open 30 | } { 31 | code {// initialize variables 32 | strcpy(file_name_,"noname.xyz"); 33 | strcpy(directory_,"./");} {} 34 | Fl_Window _wcnt { 35 | label Contour open 36 | private xywh {331 210 770 510} type Double resizable 37 | code0 {\#include } visible 38 | } { 39 | Fl_Box ct3 { 40 | label {No hay OpenGL presente} 41 | xywh {172 3 593 472} box THIN_DOWN_BOX resizable 42 | code0 {//ct3->cntData(d);} 43 | class fl_gl_contour 44 | } 45 | Fl_Group {} {open 46 | xywh {5 480 760 25} box THIN_DOWN_BOX 47 | } { 48 | Fl_Slider sc { 49 | label Scale 50 | callback {ct3->scale(sc->value()); 51 | ct3->redraw();} 52 | xywh {631 485 130 12} type Horizontal align 4 step 0.02 value 1 53 | } 54 | Fl_Slider _z { 55 | label Zoom 56 | callback {ct3->zoom(_z->value()); 57 | ct3->redraw();} 58 | xywh {430 485 130 12} type Horizontal align 4 step 0.02 value 0.8 59 | } 60 | } 61 | Fl_Group {} {open 62 | xywh {5 5 166 470} box THIN_DOWN_BOX 63 | } { 64 | Fl_Group {} {open 65 | xywh {10 6 157 49} 66 | } { 67 | Fl_Button {} { 68 | label {@fileopen} 69 | callback {// 70 | Fl_File_Chooser *p = new Fl_File_Chooser(directory_,"*.xyz",1,"Select file"); 71 | p->directory(directory_); 72 | p->show(); 73 | while( p->visible()) 74 | Fl::wait(); 75 | if(p->value()){ 76 | strcpy(file_,p->value()); 77 | strcpy(directory_,p->directory()); 78 | f = fl_filename_name(p->value()); 79 | strcpy(file_name_,f); 80 | _xyz_file->value(file_name_); 81 | button_data->activate(); 82 | }} selected 83 | tooltip {open a XYZ data file} xywh {13 7 43 28} box THIN_UP_BOX color 17 labelsize 19 labelcolor 51 84 | code1 {\#include} 85 | code2 {\#include} 86 | } 87 | Fl_Button button_data { 88 | callback {// 89 | load_xyz_data(); 90 | button_graph->activate(); 91 | control_panel->activate();} 92 | tooltip {load data} image {../img/data.xpm} xywh {67 7 43 28} box THIN_UP_BOX color 26 deactivate 93 | } 94 | Fl_Button button_graph { 95 | callback {// 96 | _chk_cut->activate(); 97 | build_graph();} 98 | tooltip {compute contourand color maps} image {../img/contour.xpm} xywh {121 7 43 28} box THIN_UP_BOX color 3 align 16 deactivate 99 | } 100 | Fl_Input _xyz_file { 101 | xywh {12 35 155 20} 102 | code0 {_xyz_file->value("noname.xyz");} 103 | } 104 | } 105 | Fl_Tabs control_panel {open 106 | xywh {5 63 165 401} deactivate 107 | } { 108 | Fl_Group {} { 109 | label Settings open 110 | xywh {8 79 156 381} 111 | } { 112 | Fl_Group {} {open 113 | xywh {8 84 151 87} box THIN_DOWN_BOX 114 | } { 115 | Fl_Choice ip { 116 | label {Interpolation:} 117 | callback {// 118 | ct3->intp_method((int)ip->value()); 119 | //printf("interpolation = %i",ip->value()); 120 | ct3->graph_cb();} 121 | tooltip {select interpolation} xywh {11 104 142 21} down_box BORDER_BOX align 5 122 | code0 {o->value(0);} 123 | } { 124 | MenuItem {} { 125 | label overall 126 | callback {// 127 | ct3->intp_method((int)ip->value()); 128 | //printf("val = %i",ip->value()); 129 | ct3->graph_cb();} 130 | xywh {15 15 100 20} 131 | } 132 | MenuItem {} { 133 | label nearest 134 | callback {// 135 | ct3->intp_method((int)ip->value()); 136 | //printf("val = %i",ip->value()); 137 | ct3->graph_cb();} 138 | xywh {15 15 100 20} 139 | } 140 | MenuItem {} { 141 | label Linear 142 | callback {// 143 | ct3->intp_method((int)ip->value()); 144 | //printf("val = %i",ip->value()); 145 | ct3->graph_cb();} 146 | xywh {15 15 100 20} 147 | } 148 | } 149 | Fl_Choice pt { 150 | label {Palette:} 151 | callback {// 152 | //ct3->color_palette((int)pt->value()); 153 | //rintf("Palette = %i",(int)pt->value()); 154 | //ct3->graph_cb();} open 155 | tooltip {select palette} xywh {11 144 142 20} down_box BORDER_BOX align 5 156 | code0 {o->value(0);} 157 | } { 158 | MenuItem {} { 159 | label Gray 160 | callback {// 161 | ct3->set_palette((int)pt->value()); 162 | //printf("Palette = %i",pt->value()); 163 | ct3->graph_cb();} 164 | xywh {25 25 100 20} 165 | } 166 | MenuItem {} { 167 | label Terrain 168 | callback {// 169 | ct3->set_palette((int)pt->value()); 170 | //printf("Palette = %i",pt->value()); 171 | ct3->graph_cb();} 172 | xywh {35 35 100 20} 173 | } 174 | MenuItem {} { 175 | label Earth 176 | callback {// 177 | ct3->set_palette((int)pt->value()); 178 | //printf("Palette = %i",pt->value()); 179 | ct3->graph_cb();} 180 | xywh {55 55 100 20} 181 | } 182 | MenuItem {} { 183 | label Hsv 184 | callback {// 185 | ct3->set_palette((int)pt->value()); 186 | //printf("Palette = %i",pt->value()); 187 | ct3->graph_cb();} 188 | xywh {65 65 100 20} 189 | } 190 | MenuItem {} { 191 | label Rgb 192 | callback {// 193 | ct3->set_palette((int)pt->value()); 194 | //printf("Palette = %i",pt->value()); 195 | ct3->graph_cb();} 196 | xywh {75 75 100 20} 197 | } 198 | } 199 | } 200 | Fl_Group {} { 201 | label Grid 202 | xywh {8 190 151 30} box THIN_DOWN_BOX align 5 203 | } { 204 | Fl_Value_Input gx { 205 | label {X:} 206 | callback {ct3->set_number_x_grid((int)gx->value()); 207 | ct3->actualize();} 208 | tooltip {Grid on X direction} xywh {28 195 28 20} minimum 10 maximum 500 step 1 value 40 209 | } 210 | Fl_Value_Input gy { 211 | label {Y:} 212 | callback {ct3->set_number_y_grid((int)gy->value()); 213 | ct3->actualize();} 214 | tooltip {Grid on Y direction} xywh {77 195 28 20} minimum 10 maximum 500 step 1 value 40 215 | } 216 | Fl_Value_Input lv { 217 | label {Z:} 218 | callback {ct3->set_number_z_grid((int)lv->value()); 219 | //ct3->actualize();} 220 | tooltip {Grid on Z direction} xywh {125 195 28 20} minimum 10 maximum 500 step 1 value 30 221 | } 222 | } 223 | Fl_Group {} { 224 | label Display 225 | xywh {8 236 151 47} box THIN_DOWN_BOX align 5 226 | } { 227 | Fl_Check_Button _bx_d { 228 | label {Box } 229 | callback {// 230 | ct3->graph_box((bool)_bx_d->value()); 231 | ct3->redraw();} 232 | tooltip {Shows bounding box} xywh {16 241 65 20} down_box DOWN_BOX 233 | } 234 | Fl_Check_Button _ch_pl { 235 | label Palette 236 | callback {// 237 | ct3->graph_pal((bool)_ch_pl->value()); 238 | ct3->redraw();} 239 | tooltip {shows palette} xywh {82 241 65 20} down_box DOWN_BOX 240 | } 241 | Fl_Check_Button _ch_d { 242 | label {Data } 243 | callback {// 244 | ct3->graph_dat((bool)_ch_d->value()); 245 | ct3->redraw();} 246 | tooltip {shows loaded data points} xywh {16 261 65 20} down_box DOWN_BOX 247 | } 248 | Fl_Check_Button _ch_sp { 249 | label Points 250 | callback {// 251 | ct3->graph_mpt((bool)_ch_sp->value()); 252 | ct3->redraw();} 253 | tooltip {shiows interpolated points} xywh {82 261 65 20} down_box DOWN_BOX 254 | } 255 | } 256 | Fl_Group {} { 257 | label Graph 258 | xywh {8 300 151 54} box THIN_DOWN_BOX align 5 259 | } { 260 | Fl_Check_Button _btt_2d { 261 | label 2D 262 | callback {// 263 | if((bool)_btt_2d->value()) 264 | g2d->activate(); 265 | else g2d->deactivate(); 266 | ct3->graph_2d((bool)_btt_2d->value()); 267 | ct3->redraw();} 268 | tooltip {shows 2D graph} xywh {15 305 41 20} down_box DOWN_BOX value 1 269 | } 270 | Fl_Check_Button _btt_3d { 271 | label 3D 272 | callback {// 273 | if((bool)_btt_2d->value()) 274 | g3d->activate(); 275 | else g3d->deactivate(); 276 | ct3->graph_3d((bool)_btt_3d->value()); 277 | ct3->redraw();} 278 | tooltip {shows 3D graph} xywh {15 330 41 20} down_box DOWN_BOX value 1 279 | } 280 | Fl_Choice g2d { 281 | callback {// 282 | ct3->graph_2d((int)g2d->value()); 283 | //printf("type = %i",g->value()); 284 | ct3->graph_cb();} 285 | tooltip {select graph type} xywh {58 304 95 20} down_box BORDER_BOX align 5 286 | code0 {o->value(0);} 287 | } { 288 | MenuItem {} { 289 | label Mesh 290 | xywh {25 25 100 20} 291 | } 292 | MenuItem {} { 293 | label Contour 294 | xywh {25 25 100 20} 295 | } 296 | MenuItem {} { 297 | label Color 298 | xywh {35 35 100 20} 299 | } 300 | MenuItem {} { 301 | label {Contour-Color} 302 | xywh {45 45 100 20} 303 | } 304 | } 305 | Fl_Choice g3d { 306 | callback {// 307 | ct3->graph_3d((int)g3d->value()); 308 | //printf("type = %i",g->value()); 309 | ct3->graph_cb();} 310 | tooltip {select graph type} xywh {58 328 95 20} down_box BORDER_BOX align 5 311 | code0 {o->value(0);} 312 | } { 313 | MenuItem {} { 314 | label Mesh 315 | xywh {35 35 100 20} 316 | } 317 | MenuItem {} { 318 | label Contour 319 | xywh {35 35 100 20} 320 | } 321 | MenuItem {} { 322 | label Color 323 | xywh {45 45 100 20} 324 | } 325 | MenuItem {} { 326 | label {Contour-Color} 327 | xywh {55 55 100 20} 328 | } 329 | } 330 | } 331 | Fl_Group {} { 332 | label Duplicate 333 | xywh {8 372 151 53} box THIN_DOWN_BOX align 5 334 | } { 335 | Fl_Check_Button _chk_avg { 336 | label Average 337 | callback {// 338 | ct3->actualize(); 339 | ct3->set_average_duplicated((bool)_chk_avg->value()); 340 | _chk_del->value(false); 341 | ct3->set_remove_duplicated((bool)_chk_del->value()); 342 | //ct3->graph_cb(); 343 | //ct3->redraw();} 344 | tooltip {Make and average with duplicate data} xywh {9 376 78 20} down_box DOWN_BOX value 1 345 | } 346 | Fl_Check_Button _chk_del { 347 | label Delete 348 | callback {// 349 | ct3->actualize(); 350 | ct3->set_remove_duplicated((bool)_chk_del->value()); 351 | _chk_avg->value(false); 352 | ct3->set_average_duplicated((bool)_chk_avg->value()); 353 | //ct3->graph_cb(); 354 | //ct3->redraw();} 355 | tooltip {Remove duplicate data} xywh {89 376 63 20} down_box DOWN_BOX 356 | } 357 | Fl_Value_Input _tol { 358 | label {tolerance:} 359 | callback {// 360 | ct3->actualize(); 361 | ct3->set_duplicated_tolerance((real)_tol->value()); 362 | ct3->redraw();} 363 | tooltip {Tolerance radius} xywh {78 401 78 20} minimum 1e-09 maximum 1e+09 step 1e-06 value 0.001 364 | } 365 | } 366 | } 367 | Fl_Group {} { 368 | label Mesh open 369 | xywh {8 79 157 384} hide 370 | } { 371 | Fl_Group {} { 372 | label {Mesh limits:} 373 | xywh {11 102 153 133} box THIN_DOWN_BOX align 5 374 | } { 375 | Fl_Value_Input gx1 { 376 | label {x1:} 377 | callback {//ct3->numxcells((int)gx->value()); 378 | //ct3->actualize();} 379 | xywh {36 107 125 20} minimum -1e+09 maximum 1e+09 step 0.001 380 | } 381 | Fl_Value_Input gy1 { 382 | label {y1:} 383 | callback {//ct3->numycells((int)gy->value()); 384 | //ct3->actualize();} 385 | xywh {36 127 125 20} minimum -1e+09 maximum 1e+09 step 0.001 386 | } 387 | Fl_Value_Input gz1 { 388 | label {z1:} 389 | callback {//ct3->numlevels((int)lv->value()); 390 | //ct3->actualize();} 391 | xywh {36 147 125 20} minimum -1e+09 maximum 1e+09 step 0.001 deactivate 392 | } 393 | Fl_Value_Input gx2 { 394 | label {x2:} 395 | callback {//ct3->numxcells((int)gx->value()); 396 | //ct3->actualize();} 397 | xywh {36 170 125 20} minimum -1e+09 maximum 1e+09 step 0.001 398 | } 399 | Fl_Value_Input gy2 { 400 | label {y2:} 401 | callback {//ct3->numycells((int)gy->value()); 402 | //ct3->actualize();} 403 | xywh {36 190 125 20} minimum -1e+09 maximum 1e+09 step 0.001 404 | } 405 | Fl_Value_Input gz2 { 406 | label {z2:} 407 | callback {//ct3->numlevels((int)lv->value()); 408 | //ct3->actualize();} 409 | xywh {36 210 125 20} minimum -1e+09 maximum 1e+09 step 0.001 deactivate 410 | } 411 | } 412 | Fl_Group {} { 413 | xywh {10 236 155 21} 414 | } { 415 | Fl_Button {} { 416 | label {@2>} 417 | callback {// 418 | cgx1->value((real)gx1->value());} 419 | xywh {10 236 20 20} 420 | } 421 | Fl_Button {} { 422 | label {@2>} 423 | callback {// 424 | cgy1->value((real)gy1->value());} 425 | xywh {30 236 21 20} 426 | } 427 | Fl_Button {} { 428 | label {@2>} 429 | xywh {51 236 20 20} deactivate 430 | } 431 | Fl_Button {} { 432 | label {@2>} 433 | callback {// 434 | cgx2->value((real)gx2->value());} 435 | xywh {104 236 20 20} 436 | } 437 | Fl_Button {} { 438 | label {@2>} 439 | callback {// 440 | cgy2->value((real)gy2->value());} 441 | xywh {124 236 21 20} 442 | } 443 | Fl_Button {} { 444 | label {@2>} 445 | xywh {145 236 20 20} deactivate 446 | } 447 | Fl_Button {} { 448 | label {@2>} 449 | callback {// 450 | cgx1->value((real)gx1->value()); 451 | cgy1->value((real)gy1->value()); 452 | cgx2->value((real)gx2->value()); 453 | cgy2->value((real)gy2->value());} 454 | xywh {72 236 29 20} 455 | } 456 | } 457 | Fl_Group _sm_lm { 458 | label {Submesh:} 459 | xywh {11 273 153 170} box THIN_DOWN_BOX align 5 deactivate 460 | } { 461 | Fl_Value_Input cgx1 { 462 | label {x1:} 463 | callback {// 464 | ct3->set_submesh_limits(0,0,(real)cgx1->value()); 465 | 466 | if((bool)_chk_rf->value()){ 467 | ct3->normalize_submesh_limits(); 468 | ct3->graph_cb(); 469 | }} 470 | xywh {36 279 125 20} minimum -1e+09 maximum 1e+09 step 0.001 471 | } 472 | Fl_Value_Input cgy1 { 473 | label {y1:} 474 | callback {// 475 | ct3->set_submesh_limits(1,0,(real)cgy1->value()); 476 | 477 | if((bool)_chk_rf->value()){ 478 | ct3->normalize_submesh_limits(); 479 | ct3->graph_cb(); 480 | }} 481 | xywh {36 299 125 20} minimum -1e+09 maximum 1e+09 step 0.001 482 | } 483 | Fl_Value_Input {} { 484 | label {z1:} 485 | callback {//ct3->numlevels((int)lv->value()); 486 | //ct3->actualize();} 487 | xywh {36 319 125 20} minimum -1e+09 maximum 1e+09 step 0.001 deactivate 488 | } 489 | Fl_Value_Input cgx2 { 490 | label {x2:} 491 | callback {// 492 | ct3->set_submesh_limits(0,1,(real)cgx2->value()); 493 | 494 | if((bool)_chk_rf->value()){ 495 | ct3->normalize_submesh_limits(); 496 | ct3->graph_cb(); 497 | }} 498 | xywh {36 342 125 20} minimum -1e+09 maximum 1e+09 step 0.001 499 | } 500 | Fl_Value_Input cgy2 { 501 | label {y2:} 502 | callback {// 503 | ct3->set_submesh_limits(1,1,(real)cgy2->value()); 504 | 505 | if((bool)_chk_rf->value()){ 506 | ct3->normalize_submesh_limits(); 507 | ct3->graph_cb(); 508 | }} 509 | xywh {36 362 125 20} minimum -1e+09 maximum 1e+09 step 0.001 510 | } 511 | Fl_Value_Input {} { 512 | label {z2:} 513 | callback {//ct3->numlevels((int)lv->value()); 514 | //ct3->actualize();} 515 | xywh {36 382 125 20} minimum -1e+09 maximum 1e+09 step 0.001 deactivate 516 | } 517 | Fl_Button {} { 518 | callback {// 519 | ct3->set_submesh_limits(0,0,(real)cgx1->value()); 520 | ct3->set_submesh_limits(0,1,(real)cgx2->value()); 521 | ct3->set_submesh_limits(1,0,(real)cgy1->value()); 522 | ct3->set_submesh_limits(1,1,(real)cgy2->value()); 523 | ct3->normalize_submesh_limits(); 524 | _save_as->activate(); 525 | ct3->graph_cb();} 526 | tooltip {cut submesh} image {../img/submesh.xpm} xywh {15 410 43 28} box THIN_UP_BOX 527 | } 528 | Fl_Button _save_as { 529 | label {@filesaveas} 530 | callback {// Save a XYZ file 531 | //char * file_; 532 | Fl_File_Chooser *p = new Fl_File_Chooser(directory_,"*.xyz",2,"Save file as"); 533 | p->directory(directory_); 534 | p->show(); 535 | while( p->visible()) 536 | Fl::wait(); 537 | if(p->value()){ 538 | //file_ = (char*)p->value(); 539 | //cout<<"File Name = "<value()); 541 | strcpy(directory_,(char*)p->directory()); 542 | f = (char*)fl_filename_name(p->value()); 543 | strcpy(submesh_file_name_,(char*)f); 544 | // 545 | cout<<"File Name = "<label(_title); 609 | 610 | gx1->value(ct3->get_x_min()); 611 | gx2->value(ct3->get_x_max()); 612 | gy1->value(ct3->get_y_min()); 613 | gy2->value(ct3->get_y_max()); 614 | gz1->value(ct3->get_z_min()); 615 | gz2->value(ct3->get_z_max()); 616 | 617 | cgx1->value(ct3->get_x_min()); 618 | cgx2->value(ct3->get_x_max()); 619 | cgy1->value(ct3->get_y_min()); 620 | cgy2->value(ct3->get_y_max()); 621 | //cgz1->value(ct3->get_z_min()); 622 | //cgz2->value(ct3->get_z_max());} {} 623 | } 624 | 625 | Function {build_graph()} {open 626 | } { 627 | code {// 628 | // 629 | ct3->set_number_x_grid((int)gx->value()); 630 | ct3->set_number_y_grid((int)gy->value()); 631 | ct3->set_number_z_grid((int)lv->value()); 632 | ct3->graph_cb();} {} 633 | } 634 | -------------------------------------------------------------------------------- /fws/readme: -------------------------------------------------------------------------------- 1 | This is the fluid file workspace for GUI design. 2 | -------------------------------------------------------------------------------- /img/contour.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * contour_xpm[] = { 3 | "44 24 9 1", 4 | " c None", 5 | ". c #F1661A", 6 | "+ c #000000", 7 | "@ c #F4F112", 8 | "# c #12F417", 9 | "$ c #1247F4", 10 | "% c #E112F4", 11 | "& c #F41257", 12 | "* c #F45D12", 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 | -------------------------------------------------------------------------------- /img/data.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * data_xpm[] = { 3 | "40 28 2 1", 4 | " c None", 5 | ". c #000000", 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 | -------------------------------------------------------------------------------- /img/submesh.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * submesh_xpm[] = { 3 | "44 24 10 1", 4 | " c None", 5 | ". c #F1661A", 6 | "+ c #000000", 7 | "@ c #F4F112", 8 | "# c #12F417", 9 | "$ c #FFFFFF", 10 | "% c #1247F4", 11 | "& c #E112F4", 12 | "* c #F41257", 13 | "= c #F45D12", 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 | -------------------------------------------------------------------------------- /include/fl_contour.h: -------------------------------------------------------------------------------- 1 | // Latest modification 20/03/2008 2 | // ======================================================================== 3 | // version: 2.1 4 | // name: fl_contour.h 5 | // 6 | // Copyrigth 2002 by Edmanuel Torres A. (eetorres@gmail.com) 7 | // 8 | // This widget is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Library General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2 of the License, or (at your option) any later version 12 | // or much better FLTK license, which allow you static linking. 13 | // 14 | // This library is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | // Library General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU Library General Public 20 | // License along with this library; if not, write to the Free Software 21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | // USA. 23 | // 24 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 25 | // me for any question, I will be very grateful with your feedbacks. 26 | // Get the last version at http://eetorres.googlepages.com/fltk_en 27 | // 28 | //======================================================================== 29 | 30 | 31 | #ifndef _Fl_Contour_H_ 32 | #define _Fl_Contour_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | extern const gm_uint typet[3][3][3]; 41 | 42 | class fl_contour{ 43 | 44 | public: 45 | // 46 | Geom_3D_Mesh triangle_color_mesh; 47 | Geom_Edges delaunay_vertex; 48 | Geom_Group square_grid; 49 | Geom_Contour line_3d_contour; 50 | vector line_2d_contour; 51 | // 52 | gm_uint xcells, ycells, _lvls; 53 | gm_real dz, zmin; 54 | gm_short _choose; 55 | // 56 | fl_contour(); 57 | virtual ~fl_contour(); 58 | // Initialization functions 59 | void initialize_data(void); 60 | // Interpolation functions 61 | void inverse_distance_interp(void); 62 | void nearest_neighbor_interp(void); 63 | void lineal_interpolation(void); 64 | // eval 65 | void eval_contour_map(bool); 66 | void eval_color_map(void); 67 | // set 68 | void set_input_data(TMatrix& mtdata); 69 | void set_max_vertex(gm_uint u){ EMAX=u;}; 70 | void set_remove_duplicated(bool b){ _delete_duplicate = b;}; 71 | void set_average_duplicated(bool b){ _average_duplicate = b;}; 72 | void set_duplicated_tolerance(gm_real r){ _duplicate_tolerance = r*r;}; 73 | void set_max_nearest_neighbour(gm_uint u){ _near_points = u;}; 74 | void set_number_x_grid(gm_uint u){ xcells = u;}; 75 | void set_number_y_grid(gm_uint u){ ycells = u;}; 76 | void set_number_z_grid(gm_uint u){ _lvls = u;}; 77 | void set_submesh_limits(int,int,real); 78 | void set_palette(gm_uint); 79 | // get 80 | gm_uint get_max_vertex(void){ return EMAX;}; 81 | gm_real get_grid_limits(int _i, int _j){return _m_grid_limits[_i][_j];}; 82 | gm_real get_x_min(void){return _m_grid_limits[0][0];}; 83 | gm_real get_x_max(void){return _m_grid_limits[0][1];}; 84 | gm_real get_y_min(void){return _m_grid_limits[1][0];}; 85 | gm_real get_y_max(void){return _m_grid_limits[1][1];}; 86 | gm_real get_z_min(void){return _m_grid_limits[2][0];}; 87 | gm_real get_z_max(void){return _m_grid_limits[2][1];}; 88 | gm_real get_submesh_limits(int,int); 89 | TMatrix get_normalize_submesh_limits(void); 90 | // 91 | void normalize_submesh_limits(void); 92 | void save_xyz_submesh(char*); 93 | 94 | fl_palette _cpalette; 95 | 96 | private: 97 | 98 | virtual void draw(){}; 99 | int handle(int event); 100 | // 101 | TMatrix _m_input_data, _m_grid_limits; 102 | TMatrix _cut_lim, _nor_lim; 103 | vector _type_triangle_list; 104 | Geom_3D_Mesh _triangle_mesh; 105 | // 106 | gm_int CONTOUR_INIT_X, CONTOUR_INIT_Y; 107 | gm_int CONTOUR_INIT_WIDTH, CONTOUR_INIT_HEIGHT; 108 | gm_int POSY, POSX; 109 | gm_uint EMAX; 110 | // 111 | Geom_Edges _vtriangle; 112 | Geom_Edges _vsquare; 113 | // 114 | Geom_Vertex _cc; 115 | Geom_Vertex _p1, _p2, _p3; 116 | Geom_Edges _line; 117 | Geom_3D_Triangle _Trg; 118 | // 119 | gm_uint _near_points, _number_vertices; 120 | gm_uint trimax, l[3], _view_mode, _view_method, _number_triangles; 121 | gm_real xmin, xmax, ymin, ymax, zmax; 122 | gm_real _delta_x, _delta_y, dq, sin1, sin2; 123 | gm_real _duplicate_tolerance, _ss, _radio, zscale; 124 | // 125 | bool _found[4], _delete_duplicate, _average_duplicate; 126 | // 127 | void initialize_levels_(); 128 | void compute_triangulation_(void); 129 | void eval_big_triangle_(); 130 | void delaunay_xz_(void); 131 | // 132 | inline void line_interpolation_(gm_real, gm_uint); 133 | inline Geom_Vertex linear_interpolation_(gm_int,gm_int,gm_real,gm_real); 134 | // 135 | inline gm_uint triangle_type_(gm_real); 136 | inline gm_uint is_triange_in_triangle_(void); 137 | inline bool is_point_in_triangle_(gm_real,gm_real); 138 | inline gm_int which_side_(gm_real,gm_real,gm_real,gm_real,gm_real,gm_real); 139 | // 140 | inline bool eval_cell_curvature_(Geom_Edges&); 141 | inline bool eval_circumcircle_(Geom_Triangle& o,Geom_Vertex&); 142 | inline void eval_centroide_(Geom_Triangle&); 143 | inline gm_real eval_square_radius_(Geom_Triangle&); 144 | inline gm_real eval_plane_point_(gm_real,gm_real); 145 | // 146 | void add_3d_triangle_(void); 147 | void add_3d_triangle_mesh_(void); 148 | void add_2d_line_(Geom_Edges&, gm_real); 149 | void add_3d_line_(Geom_Edges&, gm_real); 150 | // Color functions 151 | void update_palette_(void); 152 | void set_view_mode_(const int mode); 153 | void set_method_mode_(const int mode); 154 | void set_z_levels_(const gm_uint); 155 | void set_2d_triangle_(Geom_Edges&, int); 156 | }; 157 | 158 | #endif 159 | 160 | //// 161 | 162 | -------------------------------------------------------------------------------- /include/fl_gl_contour.h: -------------------------------------------------------------------------------- 1 | // Latest modification 19/03/2008 2 | // ======================================================================== 3 | // version: 1.9 4 | // name: fl_gl_contour.h 5 | // note: this widget is a c++ class based on the Fast Light Tool Kit 6 | // (FLTK) - www.fltk.org 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres A. (eetorres@gmail.com) 9 | // 10 | // This widget is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Library General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2 of the License, or (at your option) any later version 14 | // or much better FLTK license, which allow you static linking. 15 | // 16 | // This library is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Library General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Library General Public 22 | // License along with this library; if not, write to the Free Software 23 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 24 | // USA. 25 | // 26 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 27 | // me for any question, I will be very grateful with your feedbacks. 28 | // Get the last version at http://eetorres.googlepages.com/fltk_en 29 | // 30 | //======================================================================== 31 | 32 | 33 | #ifndef _Fl_2D_Gl_Contour_H_ 34 | #define _Fl_Gl_Contour_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #define HAVE_GL 1 41 | 42 | #if HAVE_GL 43 | #include 44 | #include 45 | #else 46 | #include 47 | #endif /* HAVE_GL */ 48 | 49 | #include 50 | 51 | #if HAVE_GL 52 | class fl_gl_contour : public Fl_Gl_Window , public fl_contour{ 53 | #else 54 | class fl_gl_contour : public Fl_Box { 55 | #endif /* HAVE_GL */ 56 | 57 | public: 58 | 59 | fl_gl_contour(int x,int y,int w,int h,const char *l=0); 60 | fl_gl_contour(int,int,int,int,TMatrix&,const char* l=0); 61 | 62 | void graph_cb(void); 63 | void graph_pw(void); 64 | void drawData(void); 65 | void drawBox(void); 66 | void drawPalette(void); 67 | void drawGridPoints(void); 68 | void drawobjects(void); 69 | // void redraw(void){draw();}; 70 | void graph_2d(bool _b){ _if_2d=_b;}; 71 | void graph_3d(bool _b){ _if_3d=_b;}; 72 | void graph_cut(bool _b){ _draw_cut = _b;}; 73 | void graph_dat(bool _b){ _draw_dat = _b;}; 74 | void graph_mpt(bool _b){ _draw_mpt = _b;}; 75 | void graph_box(bool _b){ _draw_box = _b;}; 76 | void graph_pal(bool _b){ _draw_pal = _b;}; 77 | void graph_dpt(bool _b){ _depth = _b;}; 78 | 79 | void bgColor(float r,float g,float b); 80 | void fgColor(float r,float g,float b); 81 | // Scale function 82 | void scale(float _f){ _scl = _f;}; 83 | void zoom(float _f){ _zoom = _f;}; 84 | void xzoom(float _f){ xZoom = _f;}; 85 | void yzoom(float _f){ yZoom = _f;}; 86 | // Set the rotation about the vertical (y ) axis 87 | void v_angle(float angle){ vAng=angle;}; 88 | // Return the rotation about the vertical (y ) axis 89 | float v_angle(){ return vAng;}; 90 | // Set the rotation about the horizontal (x ) axis 91 | void h_angle(float angle){ hAng=angle;}; 92 | // the rotation about the horizontal (x ) axis 93 | float h_angle(){return hAng;}; 94 | void panx(float _f){ xshift=_f;}; 95 | void pany(float _f){ yshift=_f;}; 96 | void actualize(void){ _mth_act=3;}; 97 | // 98 | void intp_method(gm_int _i){ intp_meth = _i;}; 99 | void graph_method(gm_int _i){ graph_meth = _i;}; 100 | void graph_3d(gm_int _i){ _gph_3d = _i;}; 101 | void graph_2d(gm_int _i){ _gph_2d = _i;}; 102 | 103 | #if HAVE_GL 104 | void drawMesh(gm_bool); 105 | void drawCntr(gm_bool); 106 | void drawMap(gm_bool); 107 | void drawCntMap(gm_bool); 108 | #else 109 | void drawMesh() { printf("Is not posible start any OpenGL device interface\n");} 110 | void drawCntr() { printf("Is not posible start any OpenGL device interface\n");} 111 | void drawMap() { printf("Is not posible start any OpenGL device interface\n");} 112 | #endif /* HAVE_GL */ 113 | #if HAVE_GL 114 | void draw(); 115 | #endif /* HAVE_GL */ 116 | 117 | protected: 118 | int handle(int); 119 | 120 | private: 121 | gm_real _xi, _xf, _yi, _yf; 122 | gm_int graph_meth, intp_meth, _gph_2d, _gph_3d; 123 | unsigned int _mth_act; 124 | 125 | bool _depth, gm_light, _if_2d, _if_3d; 126 | bool is_n_data, _draw_mpt, _draw_cut; 127 | bool _draw_dat, _draw_box, _draw_pal; // 128 | 129 | float vAng,hAng, y_off, _scl; 130 | float xZoom,yZoom, _zoom; 131 | float xshift,yshift,zshift; 132 | float fgred, fggreen, fgblue; 133 | float bgred, bggreen, bgblue; 134 | float boxv0[3]; 135 | float boxv1[3]; 136 | //// 137 | void init(); 138 | void drawCutMesh(void); 139 | 140 | }; 141 | 142 | #endif 143 | 144 | -------------------------------------------------------------------------------- /include/fl_palette.h: -------------------------------------------------------------------------------- 1 | // Latest modification 21/03/2008 2 | // ======================================================================== 3 | // version: 0.1 4 | // name: fl_pallete.h 5 | // 6 | // Copyrigth 2008 by Edmanuel Torres A. (eetorres@gmail.com) 7 | // 8 | // This widget is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Library General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2 of the License, or (at your option) any later version 12 | // or much better FLTK license, which allow you static linking. 13 | // 14 | // This library is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | // Library General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU Library General Public 20 | // License along with this library; if not, write to the Free Software 21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | // USA. 23 | // 24 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 25 | // me for any question, I will be very grateful with your feedbacks. 26 | // Get the last version at http://eetorres.googlepages.com/fltk_en 27 | // 28 | //======================================================================== 29 | 30 | #ifndef _Fl_Palette_H_ 31 | #define _Fl_Palette_H_ 32 | 33 | #include 34 | #include 35 | 36 | typedef struct { 37 | double r,g,b; 38 | } gm_rgb; 39 | 40 | class fl_palette{ 41 | 42 | public: 43 | // 44 | unsigned int xcells, ycells, _lvls, _ipalette; 45 | double xdelta1, ydelta1, xdelta2, ydelta2; 46 | double y0, y1, x0, x1, x2, x3, x4, x5; 47 | double w0, dz, zmin, zmax; 48 | gm_rgb rgb; 49 | gm_rgb cf1, cf2; 50 | 51 | std::vector _color_palette; 52 | 53 | fl_palette(); 54 | ~fl_palette(){}; 55 | // set 56 | void set_color(unsigned int); 57 | // get 58 | gm_rgb get_color(double); 59 | void initialize(double mn, double mx, unsigned int l){zmin=mn; zmax=mx; _lvls=l;}; 60 | 61 | //private: 62 | // 63 | gm_rgb hsv_palette_(double val); 64 | gm_rgb rgb_palette_(double val); 65 | gm_rgb linear_palette_(double val); 66 | gm_rgb earth_palette_(double val); 67 | gm_rgb terrain_palette_(double val); 68 | // 69 | gm_rgb palette_selection_(double val); 70 | double color_interpolation_(double,double,double); 71 | // 72 | // Color functions 73 | void update_palette_(void); 74 | void set(double w); 75 | }; 76 | 77 | #endif 78 | 79 | //// 80 | 81 | -------------------------------------------------------------------------------- /include/geometry.h: -------------------------------------------------------------------------------- 1 | // Latest modification 20/08/2006 2 | // ======================================================================== 3 | // version: 0.7 4 | // name: geometry.h 5 | // 6 | // Copyrigth 2002 by Edmanuel Torres A. (eetorres@gmail.com) 7 | // 8 | // This widget is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Library General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2 of the License, or (at your option) any later version 12 | // or much better FLTK license, which allow you static linking. 13 | // 14 | // This library is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | // Library General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU Library General Public 20 | // License along with this library; if not, write to the Free Software 21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | // USA. 23 | // 24 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 25 | // me for any question, I will be very grateful with your feedbacks. 26 | // Get the last version at http://eetorres.googlepages.com/fltk_en 27 | // 28 | //======================================================================== 29 | 30 | 31 | #ifndef _GEOMETRY_H_ 32 | #define _GEOMETRY_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | using namespace std; 41 | 42 | #define GM_EPSILON DBL_EPSILON 43 | 44 | #ifndef GM_TRUE 45 | #define GM_TRUE true 46 | #endif 47 | 48 | #ifndef GM_FALSE 49 | #define GM_FALSE false 50 | #endif 51 | 52 | #ifndef GM_RIGHT 53 | #define GM_RIGHT true 54 | #endif 55 | 56 | #ifndef GM_LEFT 57 | #define GM_LEFT false 58 | #endif 59 | 60 | #ifndef GM_3D 61 | #define GM_3D true 62 | #endif 63 | 64 | #ifndef GM_2D 65 | #define GM_2D false 66 | #endif 67 | 68 | 69 | typedef double gm_real; 70 | typedef short gm_short; 71 | typedef int gm_int; 72 | typedef unsigned int gm_uint; 73 | typedef bool gm_bool; 74 | 75 | template class Geom_Vertex{ 76 | 77 | private: 78 | gm_uint _psize; 79 | vector pdata; 80 | 81 | public: 82 | Geom_Vertex (){ 83 | _psize = pdim; 84 | pdata.resize(pdim); 85 | } 86 | 87 | ~Geom_Vertex (){}; 88 | 89 | void point2d(T x0, T y0){x() = x0; y() = y0;} 90 | void point3d(T x0, T y0, T z0){x()=x0; y()=y0; z()=z0;} 91 | void pointnd(Geom_Vertex& xyz){ x() = xyz.x(); y() = xyz.y(); z() = xyz.z();} 92 | /* 93 | Geom_Vertex& operator = (const Geom_Vertex& p1){ 94 | if (this!=&p1) { 95 | _psize = p1._psize; 96 | for(gm_uint i=0; i<_psize; i++) 97 | pdata[i] = p1.pdata[i];} 98 | return (*this); 99 | }*/ 100 | T& operator[] (gm_uint i){ 101 | #ifdef __CHECK_BOUNDS 102 | if (i<0 || i>=pdim) cerr << "Data out of range " << i << EXIT; 103 | #endif 104 | return (pdata[i]); 105 | }; 106 | //T& operator[] (gm_uint i){ 107 | Geom_Vertex& operator= (const Geom_Vertex& _v){ 108 | pdata = _v.pdata; 109 | return *this; 110 | } 111 | 112 | vector get_vec(void){ 113 | return pdata; 114 | } 115 | 116 | inline T& _xyz(gm_uint d){ return pdata[d];}; 117 | inline T& x(void){ return _xyz(0);}; 118 | inline T& y(void){ return _xyz(1);}; 119 | inline T& z(void){ return _xyz(2);}; 120 | inline void x(T d){ _xyz(0)=d;}; 121 | inline void y(T d){ _xyz(1)=d;}; 122 | inline void z(T d){ _xyz(2)=d;}; 123 | //friend class Geom_Triangle; 124 | }; 125 | 126 | //============================================================// 127 | 128 | template class Geom_Edges{ 129 | 130 | private: 131 | gm_uint _vsize, nv; 132 | vector< Geom_Vertex > vdata; 133 | 134 | public: 135 | 136 | Geom_Edges(){ 137 | nv = 0; _vsize = vsize; 138 | vdata.resize(_vsize); 139 | } 140 | ~Geom_Edges(){}; 141 | 142 | void resize(gm_uint _vdim){ 143 | _vsize = _vdim; 144 | vdata.resize(_vsize);} 145 | inline void null2d(gm_uint _vpos){ 146 | vdata[_vpos].x() = 0; vdata[_vpos].y() = 0;} 147 | inline void null(gm_uint _vpos){ 148 | for(gm_uint i=0; i p0){ 152 | _vsize++; nv = _vsize; vdata.push_back(p0);} 153 | inline void addlnpnt(Geom_Vertex p0){ 154 | vdata[nv] = p0; if(nv<(_vsize-1)) nv++;} 155 | inline void addlnpnt(Geom_Vertex p0, gm_uint pos){ 156 | vdata[pos] = p0; if(pos>nv) nv=pos;} 157 | inline void add3(gm_uint _p, Geom_Vertex p0, Geom_Vertex p1, Geom_Vertex p2){ 158 | vdata[_p] = p0; vdata[_p+1] = p1; vdata[_p+2] = p2; nv = _p + 3;} 159 | inline void reset(void){nv=0;} 160 | inline bool comp_xx(gm_uint e0, gm_uint e1){ 161 | T data = (int)(vdata[e0].x() - vdata[e1].x()); 162 | return abs(data)<= GM_EPSILON; 163 | } 164 | inline bool comp_yy(gm_uint e0,unsigned int e1){ 165 | T data = (int)(vdata[e0].y() - vdata[e1].y()); 166 | return abs(data)<= GM_EPSILON; 167 | } 168 | inline bool comp_xy(int e0, int e1){ 169 | T data = (int)(vdata[e0].x() - vdata[e1].y()); 170 | return abs(data)<= GM_EPSILON; 171 | } 172 | inline bool nonull(int e){ 173 | return(vdata[e].x() != 0 && vdata[e].y() != 0);} 174 | inline void size(int _dim){nv = _dim;} 175 | gm_uint size(void){return _vsize;} 176 | inline void addvertex(gm_uint n){nv = nv+n;} 177 | void delete_last(void){ vdata.pop_back(); nv--; _vsize--;}; 178 | inline T& x(gm_uint p){return vdata[p].x();} 179 | inline T& y(gm_uint p){return vdata[p].y();} 180 | inline T& z(gm_uint p){return vdata[p].z();} 181 | 182 | Geom_Edges& operator = (const Geom_Edges& p1){ 183 | if (this!=&p1){ 184 | nv = p1.nv; _vsize = p1._vsize; 185 | for(gm_uint i=0; i<_vsize; i++) 186 | vdata[i] = p1.vdata[i]; 187 | } 188 | return (*this); 189 | } 190 | 191 | Geom_Vertex& operator[] (gm_uint r){ 192 | #ifdef __CHECK_BOUNDS 193 | if (r<0 || r>=_vsize) 194 | cerr << "Vector fuera de rango " << r << EXIT; 195 | #endif 196 | return (vdata[r]); 197 | } 198 | }; 199 | 200 | ////////////////////////////////////////////////////////////////////// 201 | 202 | template class Geom_Contour{ 203 | private: 204 | gm_uint csize; 205 | vector< Geom_Edges > cdata; 206 | 207 | public: 208 | Geom_Contour(){ 209 | csize = 0; 210 | cdata.resize(csize); 211 | } 212 | 213 | Geom_Contour(gm_uint cs){ 214 | csize = cs; 215 | cdata.resize(csize); 216 | } 217 | ~Geom_Contour(){}; 218 | 219 | void add(Geom_Edges& _v){ 220 | cdata.push_back(_v); 221 | csize++; 222 | } 223 | gm_uint size(void){ 224 | return cdata.size(); 225 | } 226 | void resize(gm_uint cs){ 227 | csize = cs; 228 | cdata.resize(cs); 229 | } 230 | void clear(void){ 231 | cdata.clear(); 232 | csize = 0; 233 | } 234 | Geom_Edges& operator[] (gm_uint r) { 235 | #ifdef __CHECK_BOUNDS 236 | if (r<0 || r>=csize) 237 | cerr << "Fuera de rango " << r << EXIT; 238 | #endif 239 | return (cdata[r]); 240 | } 241 | }; 242 | 243 | //============================================================// 244 | 245 | template class Geom_Triangle { 246 | 247 | private: 248 | Geom_Edges tdata; 249 | 250 | public: 251 | Geom_Triangle(){}; 252 | 253 | ~Geom_Triangle(){}; 254 | 255 | void data(T x0, T y0, T x1, T y1, T x2, T y2){ 256 | x(0)=x0; x(1)=x1; x(2)=x2; y(0)=y0; y(1)=y1; y(2)=y2; 257 | } 258 | inline void data(Geom_Vertex p0, Geom_Vertex p1, Geom_Vertex p2){ 259 | tdata[0] = p0; tdata[1] = p1; tdata[2] = p2; 260 | } 261 | inline bool collinear(void){ 262 | if((fabs(y(0)-y(1)) <= GM_EPSILON) && (fabs(y(1)-y(2)) <= GM_EPSILON)){ 263 | return GM_TRUE;} 264 | return GM_FALSE; 265 | } 266 | inline T& x(int p){return tdata[p].x();} 267 | inline T& y(int p){return tdata[p].y();} 268 | inline T& z(int p){return tdata[p].z();} 269 | Geom_Vertex& operator[] (gm_uint r) { 270 | #ifdef __CHECK_BOUNDS 271 | if (r<0 || r>=3) 272 | cerr << "Fila fuera de rango " << r << EXIT; 273 | #endif 274 | return (tdata[r]); 275 | } 276 | }; 277 | 278 | template class Geom_2D_Triangle { 279 | 280 | private: 281 | Geom_Edges tdata; 282 | 283 | public: 284 | Geom_2D_Triangle(){}; 285 | 286 | ~Geom_2D_Triangle(){}; 287 | 288 | void data(T x0, T y0, T x1, T y1, T x2, T y2){ 289 | x(0)=x0; x(1)=x1; x(2)=x2; y(0)=y0; y(1)=y1; y(2)=y2; 290 | } 291 | 292 | inline void data(Geom_Vertex p0, Geom_Vertex p1, Geom_Vertex p2){ 293 | tdata[0] = p0; tdata[1] = p1; tdata[2] = p2; 294 | } 295 | 296 | inline bool collinear(void){ 297 | if((fabs(y(0)-y(1)) <= GM_EPSILON) && (fabs(y(1)-y(2)) <= GM_EPSILON)){ 298 | return GM_TRUE;} 299 | return GM_FALSE; 300 | } 301 | 302 | inline T& x(int p){return tdata[p].x();} 303 | inline T& y(int p){return tdata[p].y();} 304 | 305 | Geom_Vertex& operator[] (gm_uint r) { 306 | #ifdef __CHECK_BOUNDS 307 | if (r<0 || r>=3) 308 | cerr << "Fila fuera de rango " << r << EXIT; 309 | #endif 310 | return (tdata[r]); 311 | } 312 | 313 | Geom_2D_Triangle& operator = (const Geom_2D_Triangle& p1){ 314 | //if (this!=&p1) tdata=p1.data; 315 | return *this; 316 | } 317 | 318 | }; 319 | 320 | template class Geom_3D_Triangle { 321 | 322 | private: 323 | Geom_Edges tdata; 324 | 325 | public: 326 | Geom_3D_Triangle(){}; 327 | ~Geom_3D_Triangle(){}; 328 | 329 | void data(T x0, T y0, T x1, T y1, T x2, T y2){ 330 | x(0)=x0; x(1)=x1; x(2)=x2; y(0)=y0; y(1)=y1; y(2)=y2;} 331 | 332 | inline void data(Geom_Vertex p0, Geom_Vertex p1, Geom_Vertex p2){ 333 | tdata[0] = p0; tdata[1] = p1; tdata[2] = p2;} 334 | 335 | inline bool collinear(void){ 336 | if((fabs(y(0)-y(1)) <= GM_EPSILON) && (fabs(y(1)-y(2)) <= GM_EPSILON)){ 337 | return GM_TRUE;} 338 | return GM_FALSE;} 339 | 340 | inline T& x(int p){return tdata[p].x();} 341 | inline T& y(int p){return tdata[p].y();} 342 | inline T& z(int p){return tdata[p].z();} 343 | 344 | Geom_3D_Triangle& operator = (const Geom_3D_Triangle& p1){ 345 | if (this!=&p1) tdata=p1.tdata; 346 | return *this; 347 | } 348 | 349 | Geom_Vertex& operator[] (gm_uint r) { 350 | #ifdef __CHECK_BOUNDS 351 | if (r<0 || r>=3) 352 | cerr << "Fila fuera de rango " << r << EXIT; 353 | #endif 354 | return (tdata[r]); 355 | } 356 | }; 357 | 358 | ////////////////////////////////////////////////////////////////////// 359 | 360 | template class Geom_Group{ 361 | 362 | private: 363 | gm_uint _csize; 364 | //Geom_Vertex tdata[3]; 365 | vector< Geom_Edges > mdata; 366 | //Geom_Vertex cc; 367 | 368 | public: 369 | Geom_Group(){ 370 | _csize = 0; 371 | mdata.resize(_csize); 372 | } 373 | 374 | Geom_Group(gm_uint cs){ 375 | _csize = cs; 376 | mdata.resize(_csize); 377 | } 378 | 379 | ~Geom_Group(){}; 380 | 381 | void add(Geom_Edges& _v){ 382 | mdata.push_back(_v); 383 | _csize++; 384 | } 385 | gm_uint size(void){ 386 | return mdata.size();} 387 | void resize(gm_uint cs){ 388 | _csize = cs; 389 | mdata.resize(cs); 390 | } 391 | void clear(void){ 392 | mdata.clear(); 393 | _csize = 0; 394 | } 395 | 396 | Geom_Edges& operator[] (gm_uint r) { 397 | #ifdef __CHECK_BOUNDS 398 | if (r<0 || r>=_csize) 399 | cerr << "Fuera de rango " << r << EXIT; 400 | #endif 401 | return (mdata[r]); 402 | } 403 | }; 404 | 405 | ///////////////////////////////////////////////////////////////////////////////// 406 | 407 | template class Geom_3D_Mesh { 408 | gm_uint msize; 409 | vector< Geom_3D_Triangle > mdata; 410 | 411 | public: 412 | Geom_3D_Mesh(){ 413 | }; 414 | 415 | ~Geom_3D_Mesh(){}; 416 | 417 | void resize(gm_int _ms){ 418 | mdata.resize(msize); 419 | } 420 | 421 | void push_back(Geom_3D_Triangle& c){ 422 | mdata.push_back(c); 423 | } 424 | 425 | void clear(){ 426 | mdata.clear(); 427 | } 428 | 429 | gm_uint size(void){ 430 | return mdata.size(); 431 | } 432 | 433 | Geom_3D_Triangle& operator[] (gm_uint r) { 434 | #ifdef __CHECK_BOUNDS 435 | if (r<0 || r>=mdata.size()) 436 | cerr << "Fila fuera de rango " << r << EXIT; 437 | #endif 438 | return mdata[r]; 439 | } 440 | }; 441 | 442 | #endif 443 | 444 | //// 445 | -------------------------------------------------------------------------------- /include/msmvtl/README: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // MSMVTL v 1.0 (Beta version) 3 | // Mini Scientific Matrix and Vector Template Library - MSMVTL 4 | // MSMVTL is a simple matrix and vector template library 5 | // 6 | // Copyrigth 2002 by Edmanuel Torres, eetorres@gmail.com 7 | // 8 | // Don't hesitate to contact me for any question, suggestion, 9 | // modification or bug. Get the latest version at: 10 | // http://msmvtl.sourceforge.net 11 | // 12 | // This library is free software; you can redistribute it and/or 13 | // modify it under the terms of the GNU Library General Public 14 | // License as published by the Free Software Foundation; either 15 | // version 2 of the License, or (at your option) any later version. 16 | // 17 | // This library is distributed in the hope that it will be useful, 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | // Library General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Library General Public 23 | // License along with this library; if not, write to the Free Software 24 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 25 | // USA. 26 | // 27 | //======================================================================== -------------------------------------------------------------------------------- /include/msmvtl/libdef.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mini Scientific Matrix and Vector Template Library - MSMVTL 3 | // MSMVTL is a simple matrix and vector template library 4 | // 5 | // FILE: libdef.h 6 | // MSMVTL definitions 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres, eetorres@gmail.com 9 | // 10 | // Don't hesitate to contact me for any question, suggestion, 11 | // modification or bug. Get the latest version at: 12 | // http://msmvtl.sourceforge.net 13 | // 14 | // This library is free software; you can redistribute it and/or 15 | // modify it under the terms of the GNU Library General Public 16 | // License as published by the Free Software Foundation; either 17 | // version 2 of the License, or (at your option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | // Library General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Library General Public 25 | // License along with this library; if not, write to the Free Software 26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 | // USA. 28 | // 29 | //======================================================================== 30 | 31 | 32 | #ifndef _DEF_H_ 33 | #define _DEF_H_ 1 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #define __CHECK_BOUNDS 43 | #define __GET_MESSAGE 44 | 45 | 46 | #ifndef NUM 47 | #define NUM 0x023 48 | #endif 49 | 50 | #ifndef TIL 51 | #define TIL 0x07E 52 | #endif 53 | 54 | #ifndef NLN 55 | #define NLN 0x00A 56 | #endif 57 | 58 | #ifndef SPC 59 | #define SPC 0x020 60 | #endif 61 | 62 | #ifndef TAB 63 | #define TAB 0x009 64 | #endif 65 | 66 | #if defined(WIN32) || defined(WIN64) 67 | #define POW(x,y) powf(x,y); 68 | #define ABS(x) abs(x); 69 | #else 70 | #define POW(x,y) pow(x,y); 71 | #define ABS(x) fabs(x); 72 | #endif 73 | 74 | #ifndef mini 75 | #define mini(a,b) (((a)<(b))?(a):(b)) 76 | #endif 77 | 78 | #ifndef maxi 79 | #define maxi(a,b) (((a)>(b))?(a):(b)) 80 | #endif 81 | 82 | #ifndef real 83 | typedef double real; 84 | #endif 85 | 86 | #ifndef lreal 87 | typedef long double lreal; 88 | #endif 89 | 90 | #ifndef uint 91 | typedef unsigned int uint; 92 | #endif 93 | 94 | enum runtime_error { END=0, EXIT=-1 }; 95 | 96 | #ifndef real 97 | typedef struct { 98 | real r,g,b; 99 | } rgb; 100 | #endif 101 | 102 | //using namespace std; 103 | 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /include/msmvtl/tmatrix: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mini Scientific Matrix and Vector Template Library - MSMVTL 3 | // MSMVTL is a simple matrix and vector template library 4 | // 5 | // FILE: tmatrix 6 | // alias for the matrix template head file 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres, eetorres@gmail.com 9 | // 10 | // Don't hesitate to contact me for any question, suggestion, 11 | // modification or bug. Get the latest version at: 12 | // http://msmvtl.sourceforge.net 13 | // 14 | // This library is free software; you can redistribute it and/or 15 | // modify it under the terms of the GNU Library General Public 16 | // License as published by the Free Software Foundation; either 17 | // version 2 of the License, or (at your option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | // Library General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Library General Public 25 | // License along with this library; if not, write to the Free Software 26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 | // USA. 28 | // 29 | //======================================================================== 30 | 31 | 32 | #ifndef _TMATRIX_ 33 | #define _TMATRIX_ 1 34 | 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/msmvtl/tmatrix.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mini Scientific Matrix and Vector Template Library - MSMVTL 3 | // MSMVTL is a simple matrix and vector template library 4 | // 5 | // FILE: tmatrix.h 6 | // the matrix template head file 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres, eetorres@gmail.com 9 | // 10 | // Don't hesitate to contact me for any question, suggestion, 11 | // modification or bug. Get the latest version at: 12 | // http://msmvtl.sourceforge.net 13 | // 14 | // This library is free software; you can redistribute it and/or 15 | // modify it under the terms of the GNU Library General Public 16 | // License as published by the Free Software Foundation; either 17 | // version 2 of the License, or (at your option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | // Library General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Library General Public 25 | // License along with this library; if not, write to the Free Software 26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 | // USA. 28 | // 29 | //======================================================================== 30 | 31 | 32 | #ifndef _TMATRIX_H_ 33 | #define _TMATRIX_H_ 1 34 | 35 | //#define _DEBUG 1 36 | 37 | #include 38 | 39 | const unsigned int min_rows=1; 40 | const unsigned int min_cols=1; 41 | 42 | template class TMatrix { 43 | 44 | private: 45 | // 46 | unsigned int u_rr, u_cc; 47 | int i_rows, i_cols, i_rows_capacity, i_precision, i_width; 48 | char _buff[1024], c_ch; 49 | std::valarray< TVector > m_data; 50 | 51 | void set(unsigned int r, unsigned int c) { 52 | i_cols = c; 53 | i_rows = r; 54 | m_data.resize(i_rows); 55 | for(unsigned int i=0; i > v_t; 63 | v_t.resize(rows()); 64 | for(i=0; i=rows()); 79 | if(inm){ 80 | #ifdef __GET_MESSAGE 81 | std::cerr << "Matrix index out of columns range "<=cols()); 91 | if(inm){ 92 | #ifdef __GET_MESSAGE 93 | std::cerr << "Matrix index out of rows range - "<= '0') && (c_ch <= '9')) || ((c_ch == '-') || (c_ch == '+') || (c_ch == '.') )) 130 | i++; 131 | else 132 | break; 133 | infile.ignore(2048,NLN); 134 | } 135 | } 136 | infile.close(); 137 | return i; 138 | } 139 | 140 | int read_file_cols(const char* f){ 141 | int i=0; 142 | double d; 143 | std::ifstream infile(f); 144 | if (!infile.is_open()){ 145 | #ifdef _DEBUG 146 | std::cerr << "The file "<> d; 166 | c_ch = infile.peek(); 167 | while(c_ch == SPC){ 168 | infile.get(); 169 | c_ch = infile.peek(); 170 | if(c_ch == NLN) 171 | break; 172 | } 173 | } 174 | } 175 | infile.close(); 176 | return i; 177 | } 178 | 179 | void read_(const char* f, unsigned int r, unsigned int c){ 180 | T d; 181 | resize(r,c); 182 | std::ifstream infile(f); 183 | for(unsigned int i=0; i> d; 199 | m_data[i][j]=d; 200 | } 201 | infile.ignore(1024,NLN); 202 | } 203 | infile.close(); 204 | } 205 | 206 | public: 207 | // 208 | TMatrix(){ 209 | init(); 210 | set(0,0); 211 | } 212 | 213 | TMatrix(unsigned int r, unsigned int c){ 214 | init(); 215 | set(r,c); 216 | } 217 | 218 | TMatrix(const char* f){ 219 | init(); 220 | read_file(f); 221 | } 222 | 223 | TMatrix(const TMatrix& m){ 224 | init(); 225 | set(m.i_rows, m.i_cols); 226 | for(unsigned int i=0; i0) && (c>0)){ 258 | read_(f,r,c); 259 | }else if((r>0) && !(c>0)){ 260 | u_cc = read_file_cols(f); 261 | read_(f,r,u_cc); 262 | }else if(!(r>0) && (c>0)){ 263 | u_rr = read_file_rows(f); 264 | read_(f,u_rr,c); 265 | }else{ 266 | u_rr = read_file_rows(f); 267 | u_cc = read_file_cols(f); 268 | read_(f,u_rr,u_cc); 269 | } 270 | }else{ 271 | return false; 272 | } 273 | return true; 274 | } 275 | 276 | void write_file(char* f){ 277 | write_file(f, i_precision); 278 | } 279 | 280 | 281 | void write_file(char* f, int _p){ 282 | std::ofstream outfile (f); 283 | precision(_p); 284 | outfile.precision(i_precision); 285 | //outfile.setf(std::ios::right, std::ios::adjustfield); 286 | outfile.setf(std::ios::fixed, std::ios::floatfield); 287 | if (outfile.bad()){ 288 | std::cerr<<" It's not enable to open the file "< inverse(void){ 348 | T q; 349 | TMatrix m_t; 350 | m_t = (*this); 351 | for(unsigned int i= 0; i < rows(); i++){ 352 | //q = ABS(m_t[i][i]); 353 | //if(q <= _EPSILON) return 0; 354 | q = (1.0/m_t[i][i]); 355 | m_t[i][i] = 1.0; 356 | for(unsigned int k = 0; k m_t; 377 | if( if_square() ){ 378 | for(unsigned int i=0; i abs_cols(void){ 432 | TVector v_t(rows()); 433 | for(unsigned int i=0; i norm_cols(void){ 439 | TVector v_t(rows()); 440 | for(unsigned int i=0; i sum_rows(void){ 446 | TVector v_t1(cols()); 447 | TVector v_t2(rows()); 448 | for(unsigned int i=0; i sum_cols(void){ 456 | TVector v_t(rows()); 457 | for(unsigned int i=0; i v_t; 464 | for(unsigned int i=0; i m_data[j][c]){ 467 | v_t = m_data[i]; 468 | m_data[i] = m_data[j]; 469 | m_data[j] = v_t; 470 | } 471 | } 472 | } 473 | } 474 | 475 | void add_row(TVector& v){ 476 | if( cols() == v.size() ){ 477 | reset(rows()+1, cols()); 478 | m_data[rows()-1]=v; 479 | }else{ 480 | #ifdef __GET_MESSAGE 481 | printf("number of columns must be equals\n"); 482 | #endif 483 | } 484 | } 485 | 486 | void add_rows(TMatrix& m){ 487 | unsigned int u = rows(); 488 | if( cols() == m.cols() ){ 489 | reset(rows()+m.rows(), cols()); 490 | for(unsigned int i=0; i& v){ 500 | if( rows() == v.size() ){ 501 | for(unsigned int i=0; i& m){ 512 | TVector v_t; 513 | if( rows() == m.rows() ){ 514 | for(unsigned int i=0; i get_col(int i) { 526 | TVector v_t(rows()); 527 | if(!isncol(i)){ 528 | for(unsigned int r=0; r get_col(int i) const{ 535 | return get_col(i); 536 | } 537 | 538 | TVector get_diag(void){ 539 | TVector v_t(rows()); 540 | if(if_square()) 541 | for(int r=0; r _v1=get_col(i); 588 | T _max = _v1.get_max(); 589 | return _max; 590 | } 591 | 592 | // alpha: added 20/03/2011 593 | T col_min(unsigned int i){ 594 | TVector _v1=get_col(i); 595 | T _min = _v1.get_min(); 596 | return _min; 597 | } 598 | 599 | T get_max(void){ 600 | double _max = rows()>0?m_data[0].get_max():0; 601 | for(unsigned int i=1; i0?m_data[0].get_min():0; 609 | for(unsigned int i=1; i& operator[] (const int i){ 627 | #ifdef __CHECK_BOUNDS 628 | isnrow(i); 629 | #endif 630 | return m_data[i]; 631 | } 632 | 633 | // beta: added 08/03/2011 634 | const TVector& operator[] (const int i) const{ 635 | return m_data[i]; 636 | } 637 | 638 | TMatrix& operator= (const TMatrix& m){ 639 | if(this != &m){ 640 | if(this->i_rows != m.i_rows || this->i_cols != m.i_cols) 641 | set(m.i_rows, m.i_cols); 642 | m_data = m.m_data; 643 | } 644 | return *this; 645 | } 646 | 647 | // modified 08/03/2011 648 | friend TMatrix operator* (const TMatrix& m1, const TMatrix& m2){ 649 | TMatrix v_t(m1.i_rows, m2.i_cols), m_t; 650 | //TVector _v1; 651 | m_t = m2; 652 | m_t.transpose(); 653 | for (int i=0; i operator* (const TMatrix& m, const TVector& v){ 663 | TVector v_t(m.i_rows); 664 | //if(_m1.cols == v_t.size()){ 665 | for (int i=0; i operator* (const TVector& v, const TMatrix& m){ 674 | TVector v_t(m.i_rows); 675 | TMatrix m_t; 676 | m_t = m; 677 | m_t.transpose(); 678 | for (int i=0; i operator* (const T d, const TMatrix& m){ 684 | TMatrix m_t; 685 | m_t.set(m.i_rows, m.i_cols); 686 | for(int i=0; i operator/ (const TMatrix& m, const T d){ 692 | TMatrix v_t; 693 | v_t.set(m.i_rows,m.i_cols); 694 | T inv_d = 1.0/d; 695 | for(int i=0; i operator+ (const TMatrix& m1, const TMatrix& m2){ 701 | TMatrix v_t; 702 | v_t.set(m1.i_rows, m1.i_cols); 703 | for(int i=0; i operator+ (const TMatrix& m, const TVector& v){ 709 | TMatrix v_t; 710 | v_t.set(m.i_rows, m.i_cols); 711 | for(int i=0; i operator- (const TMatrix& m, T r){ 717 | TMatrix v_t; 718 | v_t.set(m.i_rows, m.i_cols); 719 | for(int i=0; i operator- (const TMatrix& m, const TVector& v){ 725 | TMatrix v_t; 726 | v_t.set(m.i_rows, m.i_cols); 727 | for(int i=0; i operator- (const TMatrix& m1, const TMatrix& m2){ 733 | TMatrix v_t; 734 | v_t.set(m1.i_rows, m1.i_cols); 735 | for(int i=0; i& m){ 741 | o <<" {"<=0) _o << " "; 747 | o.width(m.i_width); 748 | o < 32 | 33 | template inline _T m_get_intervals(_T _m){ 34 | _T _intv(_m.cols(),2); 35 | TVector _t; 36 | for(unsigned int i=0; i<_m.cols(); i++){ 37 | _t = _m.get_col(i); 38 | _intv[i][0] =_t.get_min(); 39 | _intv[i][1] =_t.get_max(); 40 | } 41 | return _intv; 42 | } 43 | 44 | template _T m_normalize_ranges(_T _m1, _T _m2){ 45 | TVector _t; 46 | _T _m(_m1.rows(),0); 47 | for(unsigned int i=0; i<_m1.cols(); i++){ 48 | _t = _m1.get_col(i); 49 | _t = vnormrange(_t,_m2[i]); 50 | _m.add_col(_t); 51 | } 52 | return _m; 53 | } 54 | 55 | template _T m_rescale(_T _m1, _T _m2){ 56 | TVector _t; 57 | _T _m(_m1.rows(),0); 58 | for(unsigned int i=0; i<_m1.cols(); i++){ 59 | _t = _m1.get_col(i); 60 | _t = vrange(_t,_m2[i]); 61 | _m.add_col(_t); 62 | } 63 | return _m; 64 | } 65 | 66 | #endif 67 | 68 | // 69 | 70 | -------------------------------------------------------------------------------- /include/msmvtl/tmmath.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mini Scientific Matrix and Vector Template Library - MSMVTL 3 | // MSMVTL is a simple matrix and vector template library 4 | // 5 | // FILE: tmmath.h 6 | // math operation for the matrix template 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres, eetorres@gmail.com 9 | // 10 | // Don't hesitate to contact me for any question, suggestion, 11 | // modification or bug. Get the latest version at: 12 | // http://msmvtl.sourceforge.net 13 | // 14 | // This library is free software; you can redistribute it and/or 15 | // modify it under the terms of the GNU Library General Public 16 | // License as published by the Free Software Foundation; either 17 | // version 2 of the License, or (at your option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | // Library General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Library General Public 25 | // License along with this library; if not, write to the Free Software 26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 | // USA. 28 | // 29 | //======================================================================== 30 | 31 | 32 | #ifndef _TMMATH_H_ 33 | #define _TMMATH_H_ 1 34 | 35 | #include 36 | 37 | template inline TVector mtrace(_T _m){ 38 | TVector _tv(_m.rows()); 39 | if(_m.is_square()){ 40 | for(unsigned int i=0; i<_tv.size(); i++) 41 | _tv[i] = _m[i][i]; 42 | } 43 | return _tv; 44 | } 45 | 46 | template inline _T mnormalize( _T _m, _T _p){ 47 | real min_scale, max_scale, _k; 48 | TVector _t; 49 | _T _tm(_m.rows(),0); 50 | for(unsigned int i=0; i<_m.cols(); i++){ 51 | min_scale = _p[i][0]; 52 | max_scale = _p[i][1]; 53 | _t = _m.get_col(i); 54 | if(-min_scale != max_scale){ 55 | _k = 0.5*(max_scale+min_scale); 56 | _t = (_t - _k); 57 | _t = (1.0/_k)*_t; 58 | }else 59 | _t = (1.0/max_scale)*_t; 60 | _tm.add_col(_t); 61 | } 62 | return _tm; 63 | } 64 | 65 | template inline _T minterval(_T _m){ 66 | _T _intv(_m.cols(),2); 67 | TVector _t; 68 | for(unsigned int i=0; i<_m.cols(); i++){ 69 | _t = _m.get_col(i); 70 | _intv[i][0] =_t.get_min(); 71 | _intv[i][1] =_t.get_max(); 72 | } 73 | return _intv; 74 | } 75 | 76 | template _T mnormrange(_T _m1, _T _m2){ 77 | TVector _t; 78 | _T _m(_m1.rows(),0); 79 | for(unsigned int i=0; i<_m1.cols(); i++){ 80 | _t = _m1.get_col(i); 81 | _t = vnormrange(_t,_m2[i]); 82 | _m.add_col(_t); 83 | } 84 | return _m; 85 | } 86 | 87 | template _T mrange(_T _m1, _T _m2){ 88 | TVector _t; 89 | _T _m(_m1.rows(),0); 90 | for(unsigned int i=0; i<_m1.cols(); i++){ 91 | _t = _m1.get_col(i); 92 | _t = vrange(_t,_m2[i]); 93 | _m.add_col(_t); 94 | } 95 | return _m; 96 | } 97 | 98 | template _T mscalexy(_T _m, _T _ml, real _ss){ 99 | unsigned int i; 100 | TVector _t(_m.rows()); 101 | _T _tm(_m.rows(),0); 102 | for(i=0; i<_m.cols()-1; i++){ 103 | _t = _m.get_col(i); 104 | _t = vscale(_t,0.5*(_ml[i][0]+_ml[i][1]),_ss); 105 | _tm.add_col(_t); 106 | } 107 | _t = _m.get_col(i); 108 | _t = vscale(_t-0.5,0.5*(_ml[i][0]+_ml[i][1]),_ml[i][1]-_ml[i][0]); 109 | _tm.add_col(_t); 110 | return _tm; 111 | } 112 | 113 | template _T mnormxy(_T _m, _T _ml, real _ss){ 114 | unsigned int i; 115 | TVector _t(_m.rows()); 116 | _T _tm(_m.rows(),0); 117 | for(i=0; i<_m.cols()-1; i++){ 118 | _t = _m.get_col(i); 119 | _t = vnormalize(_t,0.5*(_ml[i][0]+_ml[i][1]),_ss); 120 | _tm.add_col(_t); 121 | } 122 | _t = _m.get_col(i); 123 | _t = 0.5+vnormalize(_t,0.5*(_ml[i][0]+_ml[i][1]),(_ml[i][1]-_ml[i][0])); 124 | _tm.add_col(_t); 125 | return _tm; 126 | } 127 | 128 | template _T mNormXYmat(_T _m){ 129 | unsigned int i; 130 | TVector _t(_m.rows()); 131 | _T _tm(_m.rows(),0); 132 | _T _mlim; 133 | real _ss1, _ss2; 134 | 135 | _mlim = minterval(_m); // getting scaling parameters 136 | _mlim.redim(2,2); 137 | _ss1 = (_mlim[0][1] - _mlim[0][0]); 138 | _ss2 = (_mlim[1][1] - _mlim[1][0]); 139 | real _ss = maxi(_ss1,_ss2); 140 | for(i=0; i<_m.cols()-1; i++){ 141 | _t = _m.get_col(i); 142 | _t = vnormalize(_t,0.5*(_mlim[i][0]+_mlim[i][1]),_ss); 143 | _tm.add_col(_t); 144 | } 145 | _t = _m.get_col(i); 146 | _t = vnorm(_t); 147 | _tm.add_col(_t); 148 | return _tm; 149 | } 150 | 151 | #endif 152 | 153 | // 154 | 155 | -------------------------------------------------------------------------------- /include/msmvtl/tvector: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mini Scientific Matrix and Vector Template Library - MSMVTL 3 | // MSMVTL is a simple matrix and vector template library 4 | // 5 | // FILE: tvector 6 | // alias for the vector template head file 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres, eetorres@gmail.com 9 | // 10 | // Don't hesitate to contact me for any question, suggestion, 11 | // modification or bug. Get the latest version at: 12 | // http://msmvtl.sourceforge.net 13 | // 14 | // This library is free software; you can redistribute it and/or 15 | // modify it under the terms of the GNU Library General Public 16 | // License as published by the Free Software Foundation; either 17 | // version 2 of the License, or (at your option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | // Library General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Library General Public 25 | // License along with this library; if not, write to the Free Software 26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 | // USA. 28 | // 29 | //======================================================================== 30 | 31 | 32 | #ifndef _TVECTOR_ 33 | #define _TVECTOR_ 1 34 | 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/msmvtl/tvector.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mini Scientific Matrix and Vector Template Library - MSMVTL 3 | // MSMVTL is a simple matrix and vector template library 4 | // 5 | // FILE: tvector.h 6 | // the vector template head file 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres, eetorres@gmail.com 9 | // 10 | // Don't hesitate to contact me for any question, suggestion, 11 | // modification or bug. Get the latest version at: 12 | // http://msmvtl.sourceforge.net 13 | // 14 | // This library is free software; you can redistribute it and/or 15 | // modify it under the terms of the GNU Library General Public 16 | // License as published by the Free Software Foundation; either 17 | // version 2 of the License, or (at your option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | // Library General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Library General Public 25 | // License along with this library; if not, write to the Free Software 26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 | // USA. 28 | // 29 | //======================================================================== 30 | 31 | 32 | #ifndef _TVECTOR_H_ 33 | #define _TVECTOR_H_ 1 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | const short min_cap=1; 40 | 41 | template class TVector{ 42 | 43 | protected: 44 | uint u_rr; 45 | std::valarray v_data; 46 | 47 | private: 48 | char ch; 49 | uint i_prs; 50 | 51 | void resize_(uint u){ 52 | unsigned int u_d; 53 | std::valarray v_t = v_data; 54 | v_data.resize(u); 55 | u_d = mini(v_t.size(),u); 56 | for(unsigned int i=0; i=v_data.size()); 63 | if(b){ 64 | #ifdef __GET_MESSAGE 65 | std::cerr << "Index out of range - "<= '0') && (ch <= '9')) || ((ch == '-') || (ch == '+'))) 102 | i++; 103 | else 104 | break; 105 | infile.ignore(1024,NLN); 106 | } 107 | } 108 | infile.close(); 109 | return i; 110 | } 111 | 112 | void read_(const char* f, uint r){ 113 | T d; 114 | resize_(r); 115 | std::ifstream infile(f); 116 | for(unsigned int i=0; i> d; 131 | v_data[i]=d; 132 | infile.ignore(1024,NLN); 133 | } 134 | infile.close(); 135 | } 136 | 137 | public: 138 | // 139 | TVector(){ 140 | resize(0); 141 | init(); 142 | } 143 | 144 | TVector(uint u){ 145 | resize(u); 146 | init(); 147 | } 148 | 149 | TVector(const TVector& v){ 150 | resize(v.v_data.size()); 151 | for(uint i=0;i v){ 192 | for(uint i=0; i v_data[j]){ 219 | d = v_data[i]; 220 | v_data[i] = v_data[j]; 221 | v_data[j] = d; 222 | } 223 | } 224 | } 225 | } 226 | 227 | T sum(void){ 228 | T d=0; 229 | for (unsigned int _i=0; _i0?v_data[0]:0; 266 | for (unsigned int i=1; i0?v_data[0]:0; 273 | for (unsigned int i=1; i0){ 306 | read_(f,u); 307 | }else{ 308 | u_rr = read_file_rows(f); 309 | read_(f,u_rr); 310 | } 311 | infile.close(); 312 | return true; 313 | } 314 | 315 | void write_file(char* f){ 316 | write_file(f, 9); 317 | } 318 | 319 | void write_file(char* f, int u){ 320 | //uint i; 321 | std::ofstream outfile(f); 322 | outfile.precision(u); 323 | //outfile.setf(iosstd::right, iosstd::adjustfield); 324 | outfile.setf(std::ios::fixed, std::ios::floatfield); 325 | if (outfile.bad()){ 326 | std::cerr<<"The file can't be created "<& operator= (const TVector& v){ 351 | if (this != &v){ 352 | v_data.resize(v.v_data.size()); 353 | v_data = v.v_data; 354 | } 355 | return *this; 356 | } 357 | 358 | TVector& operator+= (const TVector& v){ 359 | if (this != &v) 360 | for (unsigned int i=0; i& operator-= (const TVector& v){ 366 | if (this != &v) 367 | for (unsigned int i=0; i operator+ (const TVector& v1, const TVector& v2){ 373 | TVector v_t; 374 | v_t.resize(v1.v_data.size()); 375 | for (unsigned int i=0; i operator+ (const TVector& v, const T d){ 381 | TVector v_t; 382 | v_t.v_data.resize(v.v_data.size()); 383 | for (unsigned int i=0; i operator+ (T d, const TVector& v){ 389 | TVector v_t; 390 | v_t = (v + d); 391 | return v_t; 392 | } 393 | 394 | friend TVector operator- (const TVector& v1, const TVector& v2){ 395 | TVector v_t; 396 | v_t.v_data.resize(v1.v_data.size()); 397 | for (unsigned int i=0; i operator- (const TVector& v, const T d){ 403 | TVector v_t; 404 | v_t.v_data.resize(v.v_data.size()); 405 | for (unsigned int i=0; i operator- (const T d, const TVector& v){ 411 | TVector v_t; 412 | v_t = (v - d); 413 | return v_t; 414 | } 415 | 416 | friend TVector operator- (const TVector& v){ 417 | TVector v_t; 418 | v_t.v_data.resize(v.v_data.size()); 419 | for (unsigned int i=0; i& v1, const TVector& v2){ 425 | double s=0; 426 | for(unsigned int i=0; i operator* (const T d, const TVector& v){ 432 | TVector v_t; 433 | v_t.v_data.resize(v.v_data.size()); 434 | for (uint i=0; i operator* (const TVector& v, const T d){ 440 | TVector v_t; 441 | v_t.v_data.resize(v.v_data.size()); 442 | for (uint i=0; i operator/ (const TVector& v1, const TVector& v2){ 448 | TVector v_t; 449 | v_t.v_data.resize(v1.v_data.size()); 450 | for (unsigned int i=0; i operator/ (const TVector& v, const T d){ 456 | TVector v_t; 457 | v_t.v_data.resize(v.v_data.size()); 458 | for (unsigned int i=0; i& v){ 464 | o <<" {"< 36 | 37 | ////////////////////////////////////////////////////////////////////////////// 38 | 39 | template _T vscale(_T _v, _Tu _shift, _Tu _scale){ 40 | _T _t(_v.size()); 41 | _t = ((_v * _scale)+_shift); 42 | return _t; 43 | } 44 | 45 | template _T vnormalize(_T _v, _Tu _shift, _Tu _scale){ 46 | _T _t(_v.size()); 47 | _t = (_v - _shift)/_scale; 48 | return _t; 49 | } 50 | 51 | template _T vrange(_T _v, _Tu _min_v, _Tu _max_v){ 52 | _T _t; 53 | double min_scale=_v.get_min(), max_scale=_v.get_max(); 54 | _t = (_v - min_scale)/(max_scale - min_scale); 55 | _t = _t*(_max_v-_min_v); 56 | _t = _t+_min_v; 57 | return _t; 58 | } 59 | 60 | template _T vnorm(_T _v){ 61 | _T _t(_v.size()); 62 | double min_scale=_v.get_min(), max_scale=_v.get_max(); 63 | _t = (_v - min_scale)/(max_scale - min_scale); 64 | return _t; 65 | } 66 | 67 | template _T vnormrange(_T _v, _T _v2){ 68 | _T _t=_v; 69 | real _p; 70 | _p = (0.5*(_v2[1]+_v2[0])); 71 | _t = (_t - _p); 72 | _p = (_v2[1]-_v2[0]); 73 | _t = (_t/_p); 74 | return _t; 75 | } 76 | 77 | template _T vrange(_T _v, _T _v2){ 78 | _T _t=_v; 79 | real _p; 80 | _p = (_v2[1]-_v2[0]); 81 | _t = (_t*_p); 82 | _p = (0.5*(_v2[1]+_v2[0])); 83 | _t = (_t + _p); 84 | return _t; 85 | } 86 | 87 | template _T vcentre( _T _v, _T _intv){ 88 | real min_scale = _intv[0]; 89 | real max_scale = _intv[1]; 90 | _T _t; 91 | _t = (_v - 0.5*(min_scale+max_scale))/(0.5*(max_scale + min_scale)); 92 | return _t; 93 | } 94 | 95 | template _T acos(_T _v){ 96 | _T _t(_v.size()); 97 | for(unsigned int i=0; i<_v.size(); i++) 98 | _t[i] = acos(_v[i]); 99 | return _t; 100 | } 101 | 102 | #endif 103 | 104 | // 105 | -------------------------------------------------------------------------------- /makeinclude: -------------------------------------------------------------------------------- 1 | 2 | CXX = g++ 3 | 4 | PRGS = contour 5 | SCRS = fl_gl_contour.cxx fl_contour.cxx fl_palette.cxx 6 | OBJS = $(SCRS:.cxx=.o) 7 | 8 | 9 | MDIR = $(shell sh -c pwd) 10 | IDIR = -I../ -I../include 11 | SDIR = $(MDIR)/../src/ 12 | ODIR = $(MDIR)/../obj/ 13 | XDIR = $(MDIR)/../bin/ 14 | TDIR = $(MDIR)/../test/ 15 | DIRS = src test bin obj 16 | 17 | OPTIM = -O2 -Wall -Wno-deprecated 18 | LMATH = -lm 19 | 20 | ######################################################## 21 | # add libraries for your system 22 | 23 | LX11R = 24 | 25 | # openSUSE 32bits system use: 26 | #LX11R = -L -lGLU -lGL -lXext -lX11 -lXft -lXinerama 27 | 28 | # Ubuntu 64bits system use: 29 | #LX11R = -L /usr/X11R6/lib64 -lGLU -lGL -lXext -lX11 30 | 31 | # 32bits system use: 32 | #LX11R = -L /usr/X11R6/lib -lGLU -lGL -lXext -lX11 33 | 34 | # for other system you must find the correct path...! 35 | ######################################################## 36 | 37 | # Fltk libraries 38 | LFLTK = $(shell fltk-config --use-gl --ldstaticflags) 39 | 40 | CFLAGS = $(OPTIM) -c 41 | LFLAGS = $(LFLTK) $(LX11R) 42 | 43 | .SUFFIXES: .cxx .o .h 44 | 45 | .cxx.o: 46 | $(CXX) $(CFLAGS) $< -o $(ODIR)$@ $(IDIR) 47 | -------------------------------------------------------------------------------- /obj/Makefile: -------------------------------------------------------------------------------- 1 | # Edmanuel Torres 21/10/2004 2 | 3 | include ../makeinclude 4 | 5 | all: $(PRGS) 6 | 7 | $(PRGS): 8 | $(CXX) -o $(XDIR)$@ $(PRGS).o $(OBJS) $(LFLAGS) 9 | 10 | clean: 11 | rm -rf *o $(PRGS) -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | include ../makeinclude 2 | 3 | all: $(OBJS) 4 | 5 | clean: 6 | rm -rf *o $(OBJS) 7 | -------------------------------------------------------------------------------- /src/fl_contour.cxx: -------------------------------------------------------------------------------- 1 | // Latest modification 20/03/2008 2 | // ======================================================================== 3 | // version: 2.1 4 | // name: gl_contour.cxx 5 | // 6 | // Copyrigth 2002 by Edmanuel Torres A. (eetorres@gmail.com) 7 | // 8 | // This widget is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Library General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2 of the License, or (at your option) any later version 12 | // or much better FLTK license, which allow you static linking. 13 | // 14 | // This library is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | // Library General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU Library General Public 20 | // License along with this library; if not, write to the Free Software 21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | // USA. 23 | // 24 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 25 | // me for any question, I will be very grateful with your feedbacks. 26 | // Get the last version at http://eetorres.googlepages.com/fltk_en 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | //#define _SHOW_MESSAGE_ 1 32 | //#define _DEBUG 1 33 | 34 | const gm_uint typet[3][3][3] = {{{0,0,8},{0,2,6},{9,5,7}},{{0,3,4},{1,0,1},{4,3,0}},{{7,5,9},{6,3,0},{8,0,0}}}; 35 | const gm_uint sidet[4][3] = {{0,2,1},{0,3,2},{3,2,1},{1,0,3}}; 36 | 37 | fl_contour::fl_contour(){ 38 | _delete_duplicate = false; 39 | _average_duplicate = true; 40 | _duplicate_tolerance = 1e-9; 41 | set_palette(0); 42 | } 43 | 44 | fl_contour::~fl_contour(){ 45 | } 46 | 47 | void fl_contour::set_input_data(TMatrix& mdt){ 48 | //TMatrix _mmt; 49 | real _ss1, _ss2; 50 | // 51 | _m_grid_limits = minterval(mdt); // getting scaling parameters 52 | _cut_lim = _m_grid_limits; 53 | //nor_lim(); 54 | // 55 | _ss1 = (_m_grid_limits[0][1] - _m_grid_limits[0][0]); 56 | _ss2 = (_m_grid_limits[1][1] - _m_grid_limits[1][0]); 57 | _ss = max(_ss1,_ss2); 58 | //cout<<"Scaling parameters="<<_m_grid_limits; 59 | //cout<<"INPUT="< t3p; 85 | gm_int duplicate = 0; 86 | gm_uint _duplicate_value; 87 | 88 | xmin = _m_input_data.get_col(0).get_min(); 89 | xmax = _m_input_data.get_col(0).get_max(); 90 | ymin = _m_input_data.get_col(1).get_min(); 91 | ymax = _m_input_data.get_col(1).get_max(); 92 | #ifdef _SHOW_MESSAGE_ 93 | printf("size = %i - cols = %i\n",_m_input_data.rows(),_m_input_data.cols()); 94 | printf("xmin = %f\n",xmin); 95 | printf("xmax = %f\n",xmax); 96 | printf("ymin = %f\n",ymin); 97 | printf("ymax = %f\n",ymax); 98 | #endif 99 | _number_vertices=_m_input_data.rows(); 100 | delaunay_vertex.resize(_number_vertices+4); 101 | trimax = 20 * (_number_vertices+10); 102 | _vtriangle.resize(trimax); 103 | for(i=0;i<_number_vertices;i++){ 104 | t3p.x()=_m_input_data[i][0]; 105 | t3p.y()=_m_input_data[i][1]; 106 | t3p.z()=_m_input_data[i][2]; 107 | delaunay_vertex.addlnpnt(t3p,i+1); 108 | } 109 | // sort the samples in x coordinate 110 | for(i=1;i<_number_vertices;i++){ 111 | for(j=i+1;j<=_number_vertices;j++){ 112 | if(delaunay_vertex[j].x() < delaunay_vertex[i].x()){ 113 | t3p = delaunay_vertex[i]; 114 | delaunay_vertex[i] = delaunay_vertex[j]; 115 | delaunay_vertex[j] = t3p; 116 | } 117 | } 118 | } 119 | if(_delete_duplicate || _average_duplicate){ 120 | // check for coincident values and delete them 121 | real _x, _y, _rr; 122 | for(i=1;i<_number_vertices;i++){ 123 | _duplicate_value = 1; 124 | for(j=i+1;j<=_number_vertices;j++){ 125 | _x = (delaunay_vertex[j].x() - delaunay_vertex[i].x()); 126 | _y = (delaunay_vertex[j].y() - delaunay_vertex[i].y()); 127 | _rr = (_x*_x)+(_y*_y); 128 | if(_rr < _duplicate_tolerance){ 129 | if(_delete_duplicate){ 130 | duplicate++; 131 | }else if(_average_duplicate){ 132 | duplicate++; 133 | _duplicate_value++; 134 | delaunay_vertex[i][2] += delaunay_vertex[j][2]; 135 | } 136 | delaunay_vertex[j] = delaunay_vertex[_number_vertices]; 137 | delaunay_vertex.null(_number_vertices); 138 | delaunay_vertex.delete_last(); 139 | j--; 140 | _number_vertices--; 141 | } 142 | } 143 | if(_average_duplicate && (_duplicate_value>1)) 144 | delaunay_vertex[i][2] = delaunay_vertex[i][2]/(real)_duplicate_value; 145 | } 146 | // sort the samples in x coordinate 147 | for(i=1;i<_number_vertices;i++){ 148 | for(j=i+1;j<=_number_vertices;j++){ 149 | if(delaunay_vertex[j].x() < delaunay_vertex[i].x()){ 150 | t3p = delaunay_vertex[i]; 151 | delaunay_vertex[i] = delaunay_vertex[j]; 152 | delaunay_vertex[j] = t3p; 153 | } 154 | } 155 | } 156 | } 157 | #ifdef _SHOW_MESSAGE_ 158 | for(i=1;i _vr; 330 | TVector _vc(3); 331 | TMatrix _mcut(0,3); 332 | for(unsigned int l=0; l GM_EPSILON ){ 478 | sh += 1.0/_vhi; 479 | hfi+= _p1.z()/_vhi; 480 | } 481 | _vx=_vsquare[corner].x()-_p2.x(); 482 | _vy=_vsquare[corner].y()-_p2.y(); 483 | _vhi = sqrt(_vx*_vx+_vy*_vy); 484 | if( _vhi > GM_EPSILON ){ 485 | sh += 1.0/_vhi; 486 | hfi+= _p2.z()/_vhi; 487 | } 488 | _vx=_vsquare[corner].x()-_p3.x(); 489 | _vy=_vsquare[corner].y()-_p3.y(); 490 | _vhi = sqrt(_vx*_vx+_vy*_vy); 491 | if( _vhi > GM_EPSILON ){ 492 | sh += 1.0/_vhi; 493 | hfi+= _p3.z()/_vhi; 494 | } 495 | _vsquare[corner].z()=(hfi/sh)-0.5; 496 | zmin = mini(zmin,_vsquare[corner].z()); 497 | zmax = maxi(zmax,_vsquare[corner].z()); 498 | _found[corner]=true; 499 | break; 500 | } 501 | } 502 | } 503 | if(_found[0] && _found[1] && _found[2] && _found[3]){ 504 | square_grid.add(_vsquare); 505 | }else if( (_tp=is_triange_in_triangle_()) ){ 506 | set_2d_triangle_(_vsquare, _tp); 507 | add_3d_triangle_mesh_(); 508 | _type_triangle_list.push_back(_tp); 509 | } 510 | } 511 | } 512 | #ifdef _SHOW_MESSAGE_ 513 | printf("Number of vertex: %i \n",square_grid.size()); 514 | printf("Lineal()\n"); 515 | #endif 516 | } 517 | 518 | // linear interpolation 519 | void fl_contour::lineal_interpolation(void){ 520 | gm_uint i, j, k, _tp, corner; 521 | square_grid.clear(); 522 | _triangle_mesh.clear(); 523 | _type_triangle_list.clear(); 524 | zmax = 0; 525 | zmin = 0; 526 | #ifdef _DEBUG 527 | printf("Lineal Interpolation\n"); 528 | #endif 529 | zmin = _m_input_data.get_col(2).get_min()-0.5; 530 | zmax = _m_input_data.get_col(2).get_max()-0.5; 531 | #ifdef _DEBUG 532 | printf("zMin = %f\n",zmin); 533 | printf("zMax = %f\n",zmax); 534 | printf("_lvls = %i\n",_lvls); 535 | //printf("dz = %f\n",dz); 536 | #endif 537 | for(j=0;j<=ycells;j++){ 538 | _vsquare[0].y() = (ymin+j*_delta_y); 539 | _vsquare[1].y() = (_vsquare[0].y()); 540 | _vsquare[2].y() = (_vsquare[0].y()+_delta_y); 541 | _vsquare[3].y() = (_vsquare[2].y()); 542 | for(i=0;i<=xcells;i++){ 543 | _vsquare[0].x() = (xmin+i*_delta_x); 544 | _vsquare[1].x() = (_vsquare[0].x()+_delta_x); 545 | _vsquare[2].x() = (_vsquare[1].x()); 546 | _vsquare[3].x() = (_vsquare[0].x()); 547 | for(corner=0;corner<4;corner++){ 548 | _found[corner] = false; 549 | for(k=0;k<_number_triangles;k++){ 550 | _p1 = delaunay_vertex[_vtriangle[k].x()]; 551 | _p2 = delaunay_vertex[_vtriangle[k].y()]; 552 | _p3 = delaunay_vertex[_vtriangle[k].z()]; 553 | if(is_point_in_triangle_(_vsquare[corner].x(), _vsquare[corner].y())){ 554 | _vsquare[corner].z()=eval_plane_point_(_vsquare[corner].x(),_vsquare[corner].y())-0.5; 555 | zmin = mini(zmin,_vsquare[corner].z()); 556 | zmax = maxi(zmax,_vsquare[corner].z()); 557 | _found[corner]=true; 558 | break; 559 | } 560 | } 561 | } 562 | if(_found[0] && _found[1] && _found[2] && _found[3]) 563 | square_grid.add(_vsquare); 564 | else if( (_tp=is_triange_in_triangle_()) ){ 565 | set_2d_triangle_(_vsquare, _tp); 566 | add_3d_triangle_mesh_(); 567 | _type_triangle_list.push_back(_tp); 568 | } 569 | } 570 | } 571 | #ifdef _SHOW_MESSAGE_ 572 | printf("Number of vertex: %i \n",square_grid.size()); 573 | printf("Lineal()\n"); 574 | #endif 575 | } 576 | 577 | // 578 | void fl_contour::eval_big_triangle_(){ 579 | gm_real dx,dy,dmax,xmid,ymid; 580 | dx = xmax - xmin; 581 | dy = ymax - ymin; 582 | dmax = (dx > dy) ? dx : dy; 583 | xmid = 0.5 * (xmax + xmin); 584 | ymid = 0.5 * (ymax + ymin); 585 | // 586 | delaunay_vertex[_number_vertices + 1].x() = xmid - 2.0 * dmax; 587 | delaunay_vertex[_number_vertices + 1].y() = ymid - dmax; 588 | delaunay_vertex[_number_vertices + 1].z() = 0.0; 589 | delaunay_vertex[_number_vertices + 2].x() = xmid; 590 | delaunay_vertex[_number_vertices + 2].y() = ymid + 2.0 * dmax; 591 | delaunay_vertex[_number_vertices + 2].z() = 0.0; 592 | delaunay_vertex[_number_vertices + 3].x() = xmid + 2.0 * dmax; 593 | delaunay_vertex[_number_vertices + 3].y() = ymid - dmax; 594 | delaunay_vertex[_number_vertices + 3].z() = 0.0; 595 | 596 | #ifdef _SHOW_MESSAGE_ 597 | printf("eval_big_triangle_\n"); 598 | printf("(%f,%f,%f)\n",delaunay_vertex[_number_vertices + 1].x(), delaunay_vertex[_number_vertices + 1].y(), delaunay_vertex[_number_vertices + 1].z()); 599 | printf("(%f,%f,%f)\n",delaunay_vertex[_number_vertices + 2].x(), delaunay_vertex[_number_vertices + 2].y(), delaunay_vertex[_number_vertices + 2].z()); 600 | printf("(%f,%f,%f)\n",delaunay_vertex[_number_vertices + 3].x(), delaunay_vertex[_number_vertices + 3].y(), delaunay_vertex[_number_vertices + 3].z()); 601 | #endif 602 | } 603 | 604 | // incremental Delaunay list of triangles in clockwise order. 605 | void fl_contour::delaunay_xz_(void){ 606 | vector _valid; 607 | gm_uint nvertex, x, y, z; 608 | gm_uint i,j,k; 609 | bool inside; 610 | // 611 | Geom_Triangle tt; 612 | Geom_Vertex _p1, _p2, _p3, _point; 613 | Geom_Vertex sp1, sp2, sp3, pnull; 614 | Geom_Edges vertex; 615 | Geom_Edges p; 616 | // 617 | vertex.resize(EMAX+1000); 618 | pnull.point2d(0,0); 619 | _valid.resize(trimax); 620 | eval_big_triangle_(); 621 | _vtriangle[0].x() = _number_vertices + 1; 622 | _vtriangle[0].y() = _number_vertices + 2; 623 | _vtriangle[0].z() = _number_vertices + 3; 624 | _valid[0] = false; 625 | _number_triangles = 1; 626 | // insert each point at due time into the triangle mesh 627 | for(i=1;i<=_number_vertices;i++){ 628 | _point.pointnd(delaunay_vertex[i]); 629 | nvertex = 0; 630 | j = 0; 631 | do{ 632 | if (!_valid[j]){ 633 | x = _vtriangle[j].x(); 634 | y = _vtriangle[j].y(); 635 | z = _vtriangle[j].z(); 636 | // discrete triangle coordinates into discrete triangle array 637 | sp1.point2d(x,y); sp2.point2d(y,z); sp3.point2d(z,x); 638 | // real triangle coordinates into gm_real coordinates array 639 | _p1=delaunay_vertex[x]; _p2=delaunay_vertex[y]; _p3=delaunay_vertex[z]; 640 | tt.data(_p1, _p2, _p3); 641 | // lies _point inside tt circle. 642 | inside = eval_circumcircle_( tt, _point); 643 | if(_cc.x() + _radio < _point.x()) 644 | _valid[j] = true; 645 | //if(_cc.y() + _radio < _point.y()) 646 | //_valid[j] = true; 647 | if (inside>0){ 648 | // check if we haven't exceeded the vertex list size 649 | if (nvertex+3 > EMAX) exit(0); 650 | vertex.add3(nvertex,sp1,sp2,sp3); 651 | // 652 | nvertex += 3; 653 | _vtriangle[j] = _vtriangle[_number_triangles-1]; 654 | _valid[j] = _valid[_number_triangles-1]; 655 | j--; 656 | _number_triangles--; 657 | } 658 | } 659 | j++; 660 | }while(j < _number_triangles); 661 | 662 | for(j=0;j trimax) exit(0); 678 | _number_triangles++; 679 | _vtriangle[_number_triangles-1].point3d(vertex[j].x(),vertex[j].y(),i); 680 | _valid[_number_triangles-1] = false; 681 | } 682 | } 683 | } 684 | i = 0; 685 | do{ 686 | if((_vtriangle[i].x() > _number_vertices) || (_vtriangle[i].y() > _number_vertices) || (_vtriangle[i].z() > _number_vertices)){ 687 | _vtriangle[i] = _vtriangle[_number_triangles-1]; 688 | i--; 689 | _number_triangles--; 690 | } 691 | i++; 692 | }while (i < _number_triangles); 693 | #ifdef _SHOW_MESSAGE_ 694 | printf("Vertex = %i, triangles = %i\n",delaunay_vertex.size(),_number_triangles); 695 | printf("Delaunay... bye bye\n"); 696 | #endif 697 | } 698 | 699 | bool fl_contour::eval_circumcircle_(Geom_Triangle& o, Geom_Vertex& p){ 700 | gm_real dx, dy, rsqr, drsqr; 701 | // look if these points are not collinear 702 | if (o.collinear()){ 703 | printf("colinear points\n"); 704 | return false; 705 | } 706 | eval_centroide_(o); 707 | rsqr = eval_square_radius_(o); 708 | _radio = sqrt(rsqr); 709 | dx = p.x() - _cc.x(); 710 | dy = p.y() - _cc.y(); 711 | drsqr = dx*dx + dy*dy; 712 | return (drsqr <= rsqr) ? true : false; 713 | } 714 | 715 | void fl_contour::eval_centroide_(Geom_Triangle& _o){ 716 | gm_real m1,m2,mx1,mx2,my1,my2; 717 | if (fabs(_o.y(1)-_o.y(0)) <= GM_EPSILON){ 718 | m2 = -(_o.x(2)-_o.x(1)) / (_o.y(2)-_o.y(1)); 719 | mx2 = 0.5 * (_o.x(1) + _o.x(2)); 720 | my2 = 0.5 * (_o.y(1) + _o.y(2)); 721 | _cc[0] = 0.5 * (_o.x(1) + _o.x(0)); 722 | _cc[1] = m2 * (_cc[0] - mx2) + my2; 723 | }else if (fabs(_o.y(2)-_o.y(1)) <= GM_EPSILON){ 724 | m1 = -(_o.x(1)-_o.x(0)) / (_o.y(1)-_o.y(0)); 725 | mx1 = 0.5 * (_o.x(0) + _o.x(1)); 726 | my1 = 0.5 * (_o.y(0) + _o.y(1)); 727 | _cc[0] = 0.5 * (_o.x(2) + _o.x(1)); 728 | _cc[1] = m1 * (_cc[0] - mx1) + my1; 729 | }else{ 730 | m1 = -(_o.x(1)-_o.x(0)) / (_o.y(1)-_o.y(0)); 731 | m2 = -(_o.x(2)-_o.x(1)) / (_o.y(2)-_o.y(1)); 732 | mx1 = 0.5 * (_o.x(0) + _o.x(1)); 733 | mx2 = 0.5 * (_o.x(1) + _o.x(2)); 734 | my1 = 0.5 * (_o.y(0) + _o.y(1)); 735 | my2 = 0.5 * (_o.y(1) + _o.y(2)); 736 | _cc[0] = (m1 * mx1 - m2 * mx2 + my2 - my1) / (m1 - m2); 737 | _cc[1] = m1 * (_cc[0] - mx1) + my1; 738 | } 739 | // Sat Nov 26 11:03:31 MST 2011: bug caught by Long To 740 | //_cc.z() = 0; 741 | } 742 | 743 | gm_real fl_contour::eval_square_radius_(Geom_Triangle& _o){ 744 | gm_real dx, dy; 745 | dx = _o.x(1) - _cc.x(); 746 | dy = _o.y(1) - _cc.y(); 747 | return (dx*dx+dy*dy); 748 | } 749 | 750 | // return the type of intersects of a triangle with a plane. 751 | gm_uint fl_contour::triangle_type_(gm_real lb){ 752 | for(gm_uint j=0; j<3; j++) 753 | if((_Trg[j].z()-zmin) > lb) 754 | l[j]=2; 755 | else if((_Trg[j].z()-zmin) < lb) 756 | l[j]=0; 757 | else 758 | l[j]=1; 759 | return typet[l[0]][l[1]][l[2]]; 760 | } 761 | 762 | // returns true if a point lies inside a triangle 763 | gm_bool fl_contour::is_point_in_triangle_(gm_real xp,gm_real yp){ 764 | int side1,side2,side3; 765 | side1 = which_side_(xp,yp,_p1.x(),_p1.y(),_p2.x(),_p2.y()); 766 | side2 = which_side_(xp,yp,_p2.x(),_p2.y(),_p3.x(),_p3.y()); 767 | side3 = which_side_(xp,yp,_p3.x(),_p3.y(),_p1.x(),_p1.y()); 768 | if (side1 == 0 && side2 == 0) 769 | return(true); 770 | if (side1 == 0 && side3 == 0) 771 | return(true); 772 | if (side2 == 0 && side3 == 0) 773 | return(true); 774 | if (side1 == 0 && (side2 == side3)) 775 | return(true); 776 | if (side2 == 0 && (side1 == side3)) 777 | return(true); 778 | if (side3 == 0 && (side1 == side2)) 779 | return(true); 780 | if ((side1 == side2) && (side2 == side3)) 781 | return(true); 782 | return(false); 783 | } 784 | 785 | // returns true if an small traingle lies inside a big triangle 786 | gm_uint fl_contour::is_triange_in_triangle_(void){ 787 | gm_uint _t; 788 | if(_found[0] && _found[1] && _found[2]) _t = 1; 789 | else if(_found[2] && _found[3] && _found[0]) _t = 2; 790 | else if(_found[1] && _found[2] && _found[3]) _t = 3; 791 | else if(_found[0] && _found[1] && _found[3]) _t = 4; 792 | else _t = 0; 793 | return _t; 794 | } 795 | 796 | gm_real fl_contour::eval_plane_point_(gm_real xp,gm_real yp){ 797 | gm_real a,b,c,d; 798 | a = _p1.y() * (_p2.z() - _p3.z()) + _p2.y() * (_p3.z() - _p1.z()) + _p3.y() * (_p1.z() - _p2.z()); 799 | b = _p1.z() * (_p2.x() - _p3.x()) + _p2.z() * (_p3.x() - _p1.x()) + _p3.z() * (_p1.x() - _p2.x()); 800 | c = _p1.x() * (_p2.y() - _p3.y()) + _p2.x() * (_p3.y() - _p1.y()) + _p3.x() * (_p1.y() - _p2.y()); 801 | d = - _p1.x() * (_p2.y() * _p3.z() - _p3.y() * _p2.z()) - _p2.x() * (_p3.y() * _p1.z() - _p1.y() * _p3.z()) - _p3.x() * (_p1.y() * _p2.z() - _p2.y() * _p1.z()); 802 | 803 | if (fabs(c) > GM_EPSILON) 804 | return(- (a * xp + b * yp + d) / c); 805 | else 806 | return(0.0); 807 | } 808 | 809 | // which side of a line a point lies 810 | int fl_contour::which_side_(gm_real x,gm_real y,gm_real x1,gm_real y1,gm_real x2,gm_real y2){ 811 | gm_real dist; 812 | dist = (y - y1) * (x2 - x1) - (y2 - y1) * (x - x1); 813 | if (dist > 0) 814 | return(-1); 815 | else if (dist < 0) 816 | return(1); 817 | else 818 | return(0); 819 | } 820 | 821 | // interpolation Subrutines 822 | void fl_contour::set_2d_triangle_(Geom_Edges& p, int _tp){ 823 | _Trg[0]=p[sidet[_tp-1][0]]; 824 | _Trg[1]=p[sidet[_tp-1][1]]; 825 | _Trg[2]=p[sidet[_tp-1][2]]; 826 | } 827 | 828 | void fl_contour::line_interpolation_(gm_real lv, gm_uint c){ 829 | if (c!=0) { 830 | switch (c) { 831 | // case 1 - line between vertices 1 and 2 832 | case 1: 833 | _line[0].x()=_Trg[0].x(); 834 | _line[0].y()=_Trg[0].y(); 835 | _line[1].x()=_Trg[1].x(); 836 | _line[1].y()=_Trg[1].y(); 837 | break; 838 | // case 2 - line between vertices 2 and 3 839 | case 2: 840 | _line[0].x()=_Trg[1].x(); 841 | _line[0].y()=_Trg[1].y(); 842 | _line[1].x()=_Trg[2].x(); 843 | _line[1].y()=_Trg[2].y(); 844 | break; 845 | // case 3 - line between vertices 3 and 1 846 | case 3: 847 | _line[0].x()=_Trg[2].x(); 848 | _line[0].y()=_Trg[2].y(); 849 | _line[1].x()=_Trg[0].z(); 850 | _line[1].y()=_Trg[0].y(); 851 | break; 852 | // case 4 - line between vertex 1 and side 2-3 853 | case 4: 854 | _line[0].x()=_Trg[0].x(); 855 | _line[0].y()=_Trg[0].y(); 856 | _line[1]=linear_interpolation_(0,1,lv,zmin); 857 | break; 858 | // case 5 - line between vertex 2 and side 3-1 859 | case 5: 860 | _line[0].x()=_Trg[1].x(); 861 | _line[0].y()=_Trg[1].y(); 862 | _line[1]=linear_interpolation_(0,2,lv,zmin); 863 | break; 864 | // case 6 - line between vertex 3 and side 1-2 865 | case 6: 866 | _line[0].x()=_Trg[0].z(); 867 | _line[0].y()=_Trg[0].y(); 868 | _line[1]=linear_interpolation_(0,2,lv,zmin); 869 | break; 870 | // case 7 - line between sides 1-2 and 2-3 871 | case 7: 872 | _line[0]=linear_interpolation_(0,2,lv,zmin); 873 | _line[1]=linear_interpolation_(0,1,lv,zmin); 874 | break; 875 | // case 8 - line between sides 2-3 and 3-1 876 | case 8: 877 | _line[0]=linear_interpolation_(1,2,lv,zmin); 878 | _line[1]=linear_interpolation_(0,2,lv,zmin); 879 | break; 880 | // case 9 - line between sides 3-1 and 1-2 881 | case 9: 882 | _line[0]=linear_interpolation_(0,1,lv,zmin); 883 | _line[1]=linear_interpolation_(2,1,lv,zmin); 884 | break; 885 | default: 886 | break; 887 | } 888 | } 889 | } 890 | 891 | Geom_Vertex fl_contour::linear_interpolation_(gm_int _i, gm_int _j, gm_real _lv, gm_real _zmn){ 892 | Geom_Vertex _vtx; 893 | register gm_real _z = (_lv-(_Trg[_i].z()-zmin))/(_Trg[_j].z()-_Trg[_i].z()); 894 | _vtx.x()=_Trg[_i].x()+(_Trg[_j].x()-_Trg[_i].x())*_z; 895 | _vtx.y()=_Trg[_i].y()+(_Trg[_j].y()-_Trg[_i].y())*_z; 896 | return _vtx; 897 | } 898 | 899 | // 900 | void fl_contour::add_2d_line_(Geom_Edges& _l, gm_real _lv){ 901 | line_2d_contour.push_back(_lv); 902 | } 903 | 904 | void fl_contour::add_3d_line_(Geom_Edges& _l, gm_real _lv){ 905 | Geom_Edges line_3d; 906 | line_3d[0].x() = _line[0].x(); 907 | line_3d[0].y() = _line[0].y(); 908 | line_3d[0].z() = (_lv); 909 | line_3d[1].x() = _line[1].x(); 910 | line_3d[1].y() = _line[1].y(); 911 | line_3d[1].z() = (_lv); 912 | line_2d_contour.push_back(_lv); 913 | line_3d_contour.add(line_3d); 914 | } 915 | 916 | void fl_contour::add_3d_triangle_(void){ 917 | triangle_color_mesh.push_back(_Trg); 918 | } 919 | 920 | void fl_contour::add_3d_triangle_mesh_(void){ 921 | _triangle_mesh.push_back(_Trg); 922 | } 923 | 924 | void fl_contour::set_palette(gm_uint u){ 925 | _cpalette.set_color(u); 926 | } 927 | 928 | void fl_contour::update_palette_(void){ 929 | dz = (zmax - zmin) / _lvls; 930 | _cpalette.initialize(zmin,zmax,_lvls); 931 | _cpalette.update_palette_(); 932 | } 933 | 934 | // submesh cutting utils 935 | void fl_contour::set_submesh_limits(int _i, int _j, real _r){ 936 | _cut_lim[_i][_j]=_r; 937 | //cout<<"Cut mesh ="<<_cut_lim; }; 938 | } 939 | 940 | void fl_contour::normalize_submesh_limits(void){ 941 | _nor_lim = _cut_lim; 942 | _nor_lim.transpose(); 943 | _nor_lim = mnormxy(_nor_lim,_m_grid_limits,_ss); 944 | _nor_lim.transpose(); 945 | _nor_lim.redim(2,2); 946 | //cout<<"Normalized Limits ="<<_nor_lim; 947 | } 948 | 949 | gm_real fl_contour::get_submesh_limits(int _i, int _j){ 950 | return _cut_lim[_i][_j]; 951 | }; 952 | 953 | TMatrix fl_contour::get_normalize_submesh_limits(void){ 954 | return _nor_lim; 955 | } 956 | 957 | /// RUBISH 958 | 959 | 960 | -------------------------------------------------------------------------------- /src/fl_gl_contour.cxx: -------------------------------------------------------------------------------- 1 | // Latest modification 19/03/2008 2 | // ======================================================================== 3 | // version: 1.9 4 | // name: fl_gl_contour.cxx 5 | // note: this widget is a c++ class based on the Fast Light Tool Kit 6 | // (FLTK) - www.fltk.org 7 | // 8 | // Copyrigth 2002 by Edmanuel Torres A. (eetorres@gmail.com) 9 | // 10 | // This widget is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Library General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2 of the License, or (at your option) any later version 14 | // or much better FLTK license, which allow you static linking. 15 | // 16 | // This library is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Library General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Library General Public 22 | // License along with this library; if not, write to the Free Software 23 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 24 | // USA. 25 | // 26 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 27 | // me for any question, I will be very grateful with your feedbacks. 28 | // Get the last version at http://eetorres.googlepages.com/fltk_en 29 | // 30 | //======================================================================== 31 | 32 | 33 | #include 34 | 35 | #define ALPHA 0.5 36 | #define HAVE_GL 1 37 | 38 | #define _SHOW_LINES_ 1 39 | //#define _SHOW_MESSAGES 1 40 | 41 | #if HAVE_GL 42 | fl_gl_contour::fl_gl_contour(int x,int y,int w,int h,const char *l) 43 | : Fl_Gl_Window(x,y,w,h,l) 44 | #else 45 | fl_gl_contour::fl_gl_contour(int x,int y,int w,int h,const char *l) : Fl_Box(x,y,w,h,l) 46 | #endif /* HAVE_GL */ 47 | { 48 | init(); 49 | } 50 | 51 | #if HAVE_GL 52 | fl_gl_contour::fl_gl_contour(int x,int y,int w,int h,TMatrix& mtx,const char *l) 53 | : Fl_Gl_Window(x,y,w,h,l) 54 | #else 55 | fl_gl_contour::fl_gl_contour(int x,int y,int w,int h,TMatrix& mtx,const char *l) : Fl_Box(x,y,w,h,l) 56 | #endif /* HAVE_GL */ 57 | { 58 | init(); 59 | set_input_data(mtx); 60 | #if !HAVE_GL 61 | label("OpenGL is required for this demo to operate."); 62 | align(FL_ALIGN_WRAP | FL_ALIGN_INSIDE); 63 | #endif /* !HAVE_GL */ 64 | } 65 | 66 | void fl_gl_contour::init() { 67 | intp_meth = 0; 68 | graph_meth = 0; 69 | _gph_3d = 0; 70 | _gph_2d = 0; 71 | _choose = 0; 72 | _mth_act = 3; 73 | 74 | xcells = 40; 75 | ycells = 40; 76 | _lvls = 40; 77 | 78 | 79 | vAng = 95.0;//Z 80 | hAng = 220.0;//XY 81 | 82 | xZoom = 1.0; 83 | yZoom = 1.0; 84 | 85 | _scl = 1; 86 | _zoom = 0.8; 87 | xshift = 0.0; 88 | yshift = 0.0; 89 | zshift = 0.0; 90 | y_off = 1.0; 91 | 92 | // Foreground colors 93 | fgred = 0.5; 94 | fggreen = 1.0; 95 | fgblue = 0.5; 96 | // Background colors 97 | bgred = 0.0; 98 | bggreen = 0.0; 99 | bgblue = 0.0; 100 | 101 | _depth = true; 102 | is_n_data = false; 103 | _draw_mpt = false; 104 | _draw_dat = false; 105 | _draw_box = false; 106 | _draw_pal = false; 107 | _draw_cut = false; 108 | gm_light = true; 109 | // 110 | _if_2d = true; 111 | _if_3d = true; 112 | 113 | set_max_vertex(500); 114 | set_max_nearest_neighbour(5); 115 | 116 | #if !HAVE_GL 117 | label("WARNING: OpenGL is required for this demo to operate."); 118 | align(FL_ALIGN_WRAP | FL_ALIGN_INSIDE); 119 | #endif /* !HAVE_GL */ 120 | } 121 | 122 | 123 | ////////////////////////////OPENGL//////////////////////////////// 124 | 125 | #if HAVE_GL 126 | 127 | void fl_gl_contour::drawMesh(gm_bool _sw) { 128 | unsigned int l; 129 | gm_rgb _rgb; 130 | glColor3f(0.8,0.1,0.1); 131 | /*// Delaunay 132 | for(unsigned int k=0;k _cut_box = get_normalize_submesh_limits(); 371 | _xi = _cut_box[0][0]; 372 | _xf = _cut_box[0][1]; 373 | _yi = _cut_box[1][0]; 374 | _yf = _cut_box[1][1]; 375 | // Bottom 376 | glBegin(GL_LINE_LOOP); 377 | glVertex3f(_xi,_yi,-0.5); 378 | glVertex3f(_xi,_yf,-0.5); 379 | glVertex3f(_xf,_yf,-0.5); 380 | glVertex3f(_xf,_yi,-0.5); 381 | glEnd(); 382 | } 383 | 384 | void fl_gl_contour::drawPalette(void){ 385 | gm_rgb _rgb; 386 | double _ds; 387 | double _hor=0.45, _h=0.05; 388 | double _ver=-0.4, _w=0.8; 389 | 390 | glLoadIdentity(); 391 | glPushMatrix(); 392 | glLineWidth(1.0); 393 | _ds = _w/_lvls; 394 | glBegin(GL_QUADS); 395 | for(unsigned int _n=0;_n<_lvls;_n++){ 396 | _rgb = _cpalette.get_color(_n*dz); 397 | glColor3f(_rgb.r,_rgb.g,_rgb.b); 398 | glVertex3f(_ver+_n*_ds, _hor , 0.8); 399 | glVertex3f(_ver+_w , _hor , 0.8); 400 | glVertex3f(_ver+_w , _hor+_h, 0.8); 401 | glVertex3f(_ver+_n*_ds, _hor+_h, 0.8); 402 | } 403 | glEnd(); 404 | 405 | glBegin(GL_LINES); 406 | glColor3f(0.5,0.5,0.0); 407 | glVertex3f(_ver,_hor+_h,0.8); 408 | glVertex3f(_ver+_w, _hor+_h, 0.8); 409 | glVertex3f(_ver+_w, _hor , 0.8); 410 | glVertex3f(_ver+_w, _hor+_h, 0.8); 411 | glVertex3f(_ver , _hor , 0.8); 412 | glVertex3f(_ver , _hor+_h, 0.8); 413 | glVertex3f(_ver , _hor , 0.8); 414 | glVertex3f(_ver+_w, _hor , 0.8); 415 | glEnd(); 416 | glPopMatrix(); 417 | } 418 | 419 | void fl_gl_contour::drawobjects(void){ 420 | if(_draw_cut) drawCutMesh(); 421 | if(_draw_dat) drawData(); 422 | if(_draw_box) drawBox(); 423 | if(_draw_mpt) drawGridPoints(); 424 | if(_draw_pal) drawPalette(); 425 | } 426 | 427 | void fl_gl_contour::draw() { 428 | if (!valid()) { 429 | glLoadIdentity(); 430 | glClearColor(bgred,bggreen,bgblue,1.0); 431 | //if(_depth){ 432 | glEnable(GL_DEPTH_TEST); // Enable Depth testing 433 | glDepthFunc(GL_LEQUAL); 434 | glShadeModel(GL_SMOOTH); // Use smooth shading 435 | glHint(GL_SHADE_MODEL,GL_NICEST); // Set the smooth shaiding to the best we can have 436 | //} 437 | glViewport (0, 0, w(), h()); 438 | glMatrixMode (GL_PROJECTION); 439 | glLoadIdentity(); 440 | if (w() <= h()) 441 | glOrtho (-0.6, 0.6, -0.6*(GLfloat)h()/(GLfloat)w(), 0.6*(GLfloat)h()/(GLfloat)w(), -10.0, 10.0); 442 | else 443 | glOrtho (-0.6*(GLfloat)w()/(GLfloat)h(), 0.6*(GLfloat)w()/(GLfloat)h(), -0.6, 0.6, -10.0, 10.0); 444 | glMatrixMode(GL_MODELVIEW); 445 | glLoadIdentity(); 446 | } 447 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 448 | glPushMatrix(); 449 | // 450 | glTranslatef(xshift, yshift, 0); 451 | glRotatef(hAng,0,1,0); 452 | glRotatef(vAng,-1,0,0); 453 | glScalef(_zoom,_zoom,_zoom); 454 | 455 | if(is_n_data){ 456 | if(_if_3d) 457 | switch(_gph_3d){ 458 | case 0: 459 | drawMesh(true); 460 | break; 461 | case 1: 462 | drawCntr(true); 463 | break; 464 | case 2: 465 | drawMap(true); 466 | break; 467 | default: 468 | drawCntMap(true); 469 | break; 470 | } 471 | if(_if_2d) 472 | switch(_gph_2d){ 473 | case 0: 474 | drawMesh(false); 475 | break; 476 | case 1: 477 | drawCntr(false); 478 | break; 479 | case 2: 480 | drawMap(false); 481 | break; 482 | default: 483 | drawCntMap(false); 484 | break; 485 | } 486 | drawobjects(); 487 | } 488 | 489 | //drawMesh(); 490 | glPopMatrix(); 491 | glFlush(); 492 | redraw(); 493 | } 494 | 495 | #endif /* HAVE_GL */ 496 | 497 | ////////////////////////////HANDLE EVENTS//////////////////////////////// 498 | 499 | int fl_gl_contour::handle(int event) { 500 | static int last_x; 501 | static int last_y; 502 | int delta_x, delta_y; 503 | //... position in Fl::event_x() and Fl::event_y() 504 | // get current mouse position and process event 505 | int x = Fl::event_x(); 506 | int y = Fl::event_y(); 507 | 508 | switch(event) { 509 | case FL_PUSH: 510 | //... mouse down event ... 511 | // save mouse position to track drag events 512 | last_x = x; 513 | last_y = y; 514 | return 1; 515 | case FL_DRAG: 516 | delta_x = x - last_x; 517 | delta_y = y - last_y; 518 | last_x = x; 519 | last_y = y; 520 | hAng += 0.2*delta_x; 521 | vAng += 0.2*delta_y; 522 | redraw(); 523 | return 1; 524 | /*case FL_RELEASE: 525 | ... mouse up event ... 526 | return 1; 527 | case FL_FOCUS : 528 | case FL_UNFOCUS : 529 | ... Return 1 if you want keyboard events, 0 otherwise 530 | return 1; 531 | case FL_KEYBOARD: 532 | ... keypress, key is in Fl::event_key(), ascii in Fl::event_text() 533 | ... Return 1 if you understand/use the keyboard event, 0 otherwise... 534 | return 1; 535 | case FL_SHORTCUT: 536 | ... shortcut, key is in Fl::event_key(), ascii in Fl::event_text() 537 | ... Return 1 if you understand/use the shortcut event, 0 otherwise... 538 | return 1;*/ 539 | default: 540 | // pass other events to the base class... 541 | return Fl_Gl_Window::handle(event); 542 | } 543 | } 544 | 545 | //////////////////////////////UTILS/////////////////////////////// 546 | 547 | void fl_gl_contour::bgColor(float r,float g,float b){ 548 | bgred=r; bggreen=g; bgblue=b; 549 | } 550 | 551 | void fl_gl_contour::fgColor(float r,float g,float b){ 552 | fgred=r; fggreen=g; fgblue=b; 553 | } 554 | 555 | void fl_gl_contour::graph_cb(void){ 556 | initialize_data(); 557 | switch(intp_meth) { 558 | case 0: 559 | if(_mth_act != 0){ 560 | inverse_distance_interp(); 561 | _mth_act = 0; 562 | } 563 | break; 564 | case 1: 565 | if(_mth_act != 1){ 566 | nearest_neighbor_interp(); 567 | _mth_act = 1; 568 | } 569 | break; 570 | default: 571 | if(_mth_act != 2){ 572 | lineal_interpolation(); 573 | _mth_act = 2; 574 | } 575 | break; 576 | } 577 | // 578 | switch(_gph_3d) { 579 | case 0: 580 | eval_color_map(); 581 | break; 582 | case 1: 583 | eval_contour_map(GM_3D); 584 | break; 585 | case 2: 586 | eval_color_map(); 587 | break; 588 | default: 589 | eval_contour_map(GM_3D); 590 | eval_color_map(); 591 | break; 592 | } 593 | if(_gph_2d != _gph_3d) 594 | switch(_gph_2d) { 595 | case 0: 596 | eval_color_map(); 597 | break; 598 | case 1: 599 | eval_contour_map(GM_3D); 600 | break; 601 | case 2: 602 | eval_color_map(); 603 | break; 604 | default: 605 | eval_contour_map(GM_3D); 606 | eval_color_map(); 607 | break; 608 | } 609 | 610 | redraw(); 611 | is_n_data = 1; 612 | #if _SHOW_MESSAGES 613 | printf("graph_cb();\n"); 614 | #endif /* !HAVE_GL */ 615 | } 616 | 617 | ///// 618 | 619 | 620 | 621 | 622 | //// 623 | 624 | -------------------------------------------------------------------------------- /src/fl_palette.cxx: -------------------------------------------------------------------------------- 1 | // Latest modification 21/03/2008 2 | // ======================================================================== 3 | // version: 0.1 4 | // name: fl_palette.cxx 5 | // 6 | // Copyrigth 2008 by Edmanuel Torres A. (eetorres@gmail.com) 7 | // 8 | // This widget is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Library General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2 of the License, or (at your option) any later version 12 | // or much better FLTK license, which allow you static linking. 13 | // 14 | // This library is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | // Library General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU Library General Public 20 | // License along with this library; if not, write to the Free Software 21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | // USA. 23 | // 24 | // Sent me suggestions, modifications or bugs. Don't hesitate to contact 25 | // me for any question, I will be very grateful with your feedbacks. 26 | // Get the last version at http://eetorres.googlepages.com/fltk_en 27 | // 28 | //======================================================================== 29 | 30 | 31 | #include 32 | 33 | fl_palette::fl_palette(void){ 34 | _ipalette = 0; 35 | } 36 | 37 | void fl_palette::set(double w){ 38 | xdelta1 = w/w0; 39 | xdelta2 = xdelta1+xdelta1; 40 | x0=xdelta1; 41 | x1=xdelta1+x0; 42 | x2=xdelta1+x1; 43 | x3=xdelta1+x2; 44 | x4=xdelta1+x3; 45 | x5=xdelta1+x4; 46 | ydelta1 = 255.0; 47 | } 48 | 49 | void fl_palette::set_color(unsigned int u){ 50 | _ipalette = u; 51 | switch(_ipalette){ 52 | case 0: 53 | w0 = 1.0;//Linear 54 | break; 55 | default: 56 | w0 = 6.0;//HSV 57 | break; 58 | } 59 | }; 60 | 61 | void fl_palette::update_palette_(void){ 62 | double lv; 63 | _color_palette.clear(); 64 | #ifdef _SHOW_MESSAGE_ 65 | printf("_lvls = %i\n",_lvls); 66 | printf("dz = %f\n",dz); 67 | #endif 68 | dz=(zmax-zmin)/_lvls; 69 | set(zmax-zmin); 70 | for(unsigned int _p=0; _p<(_lvls+1); _p++){ 71 | lv = (_p*dz); 72 | rgb = palette_selection_(lv); 73 | rgb.r/=255.0; 74 | rgb.g/=255.0; 75 | rgb.b/=255.0; 76 | //printf("r=%f, g=%f, b=%f\n",rgb.r,rgb.g,rgb.b); 77 | _color_palette.push_back(rgb); 78 | } 79 | } 80 | 81 | gm_rgb fl_palette::palette_selection_(double _x){ 82 | switch(_ipalette){ 83 | case 0: 84 | return linear_palette_(_x); 85 | break; 86 | case 1: 87 | return terrain_palette_(_x); 88 | break; 89 | case 2: 90 | return earth_palette_(_x); 91 | break; 92 | case 3: 93 | return hsv_palette_(_x); 94 | break; 95 | default: 96 | return rgb_palette_(_x); 97 | break; 98 | } 99 | } 100 | 101 | gm_rgb fl_palette::get_color(double val){ 102 | unsigned int c = (unsigned int)(val/dz); 103 | return _color_palette[c]; 104 | } 105 | 106 | double fl_palette::color_interpolation_(double dx, double dy, double _cl){ 107 | return (dy/dx)*_cl; 108 | } 109 | 110 | //// Palettes 111 | 112 | // HSV palette 113 | gm_rgb fl_palette::hsv_palette_(double val){ 114 | double rcf1=100.0; 115 | double bcf2=200.0; 116 | double gcf3=255.0; 117 | ydelta1 = 255.0; 118 | if(val >= 0 && val <= x0){ //1 119 | rgb.r=rcf1; 120 | rgb.g=0.0; 121 | rgb.b=color_interpolation_(xdelta1, bcf2, val); 122 | }else if(val > x0 && val <= x1){ //2 123 | rgb.r=rcf1-color_interpolation_(xdelta1, rcf1, val-x0); 124 | rgb.g=0.0; 125 | rgb.b=bcf2; 126 | }else if(val > x1 && val <= x2){ // 3 127 | rgb.r=0.0; 128 | rgb.g=color_interpolation_(xdelta1, gcf3, val-x1); 129 | rgb.b=bcf2; 130 | }else if(val > x2 && val <= x3){ // 4 131 | rgb.r=0.0; 132 | rgb.g=gcf3; 133 | rgb.b=bcf2-color_interpolation_(xdelta1, bcf2, val-x2); 134 | }else if(val > x3 && val <= x4){ // 5 135 | rgb.r=color_interpolation_(xdelta1, rcf1, val-x3); 136 | rgb.g=gcf3; 137 | rgb.b=0.0; 138 | }else if(val > x4 && val <= x5){ // 6 139 | rgb.r=rcf1; 140 | rgb.g=gcf3-color_interpolation_(xdelta1, gcf3, val-x4); 141 | rgb.b=0.0; 142 | } 143 | return rgb; 144 | } 145 | 146 | // Earth palette 147 | gm_rgb fl_palette::earth_palette_(double val){ 148 | cf1.r=250.0; cf1.g=250.0; cf1.b=255.0; 149 | ydelta1 = 255.0; 150 | if(val >= 0 && val <= x0){ // 1 151 | rgb.r=0.0; 152 | rgb.g=0.0; 153 | rgb.b=color_interpolation_(xdelta1, cf1.b, val); 154 | }else if(val >= x0 && val <= x1){ // 2 155 | rgb.r=0.0; 156 | rgb.g=color_interpolation_(xdelta1, cf1.g, val-x0); 157 | rgb.b=0.0; 158 | }else if(val > x1 && val <= x2){ //3 159 | rgb.r=0.0; 160 | rgb.g=cf1.g; 161 | rgb.b=0.0; 162 | }else if(val > x2 && val <= x3){ //4 163 | rgb.r=color_interpolation_(xdelta1, cf1.r, val-x2); 164 | rgb.g=cf1.g; 165 | rgb.b=0.0; 166 | }else if(val > x3 && val <= x4){ //5 167 | rgb.r=0.5*cf1.r+0.25*color_interpolation_(xdelta1, cf1.r, val-x3); 168 | rgb.g=0.5*cf1.r+0.25*color_interpolation_(xdelta1, cf1.g, val-x3); 169 | rgb.b=0.5*cf1.r+0.25*color_interpolation_(xdelta1, cf1.b, val-x3); 170 | }else if(val > x4){ //6 171 | rgb.r=0.75*cf1.r+0.25*color_interpolation_(xdelta1, cf1.r, val-x4); 172 | rgb.g=0.75*cf1.g+0.25*color_interpolation_(xdelta1, cf1.g, val-x4); 173 | rgb.b=0.75*cf1.b+0.25*color_interpolation_(xdelta1, cf1.b, val-x4); 174 | } 175 | return rgb; 176 | } 177 | 178 | // Terrain palette 179 | gm_rgb fl_palette::terrain_palette_(double val){ 180 | cf1.r=250.0; cf1.g=250.0; cf1.b=255.0; 181 | ydelta1 = 255.0; 182 | if(val >= 0 && val <= x0){ // 1 183 | rgb.r=color_interpolation_(xdelta1, 184.0, val); 184 | rgb.g=color_interpolation_(xdelta1, 134.0, val); 185 | rgb.b=color_interpolation_(xdelta1, 11.2, val); 186 | }else if(val >= x0 && val <= x1){ // 2 187 | rgb.r=0.0; 188 | rgb.g=0.6*color_interpolation_(xdelta1, cf1.g, val-x0); 189 | rgb.b=0.0; 190 | }else if(val > x1 && val <= x2){ //3 191 | rgb.r=0.0; 192 | rgb.g=0.6*cf1.g; 193 | rgb.b=0.0; 194 | }else if(val > x2 && val <= x3){ //4 195 | rgb.r=34.0+0.3*color_interpolation_(xdelta1, cf1.r, val-x2); 196 | rgb.g=0.6*cf1.g; 197 | rgb.b=34.0+0.3*color_interpolation_(xdelta1, cf1.b, val-x2);; 198 | }else if(val > x3 && val <= x4){ //5 199 | rgb.r=0.5*cf1.r+0.25*color_interpolation_(xdelta1, cf1.r, val-x3); 200 | rgb.g=0.5*cf1.r+0.25*color_interpolation_(xdelta1, cf1.g, val-x3); 201 | rgb.b=0.5*cf1.r+0.25*color_interpolation_(xdelta1, cf1.b, val-x3); 202 | }else if(val > x4){ //6 203 | rgb.r=0.75*cf1.r+0.25*color_interpolation_(xdelta1, cf1.r, val-x4); 204 | rgb.g=0.75*cf1.g+0.25*color_interpolation_(xdelta1, cf1.g, val-x4); 205 | rgb.b=0.75*cf1.b+0.25*color_interpolation_(xdelta1, cf1.b, val-x4); 206 | } 207 | return rgb; 208 | } 209 | 210 | // RGB palette 211 | gm_rgb fl_palette::rgb_palette_(double val){ 212 | cf1.r=250.0; cf1.g=250.0; cf1.b=255.0; 213 | ydelta1 = 255.0; 214 | if(val >= 0 && val <= x0){ // 1 215 | rgb.r=0.0; 216 | rgb.g=0.0; 217 | rgb.b=color_interpolation_(xdelta1, cf1.b, val); 218 | }else if(val >= x0 && val <= x1){ // 2 219 | rgb.r=0.0; 220 | rgb.g=color_interpolation_(xdelta1, cf1.g, val-x0); 221 | rgb.b=cf1.b; 222 | }else if(val > x1 && val <= x2){ //3 223 | rgb.r=0.0; 224 | rgb.g=cf1.g; 225 | rgb.b=cf1.b-color_interpolation_(xdelta1, cf1.b, val-x1); 226 | }else if(val > x2 && val <= x3){ //4 227 | rgb.r=color_interpolation_(xdelta1, cf1.r, val-x2); 228 | rgb.g=cf1.g; 229 | rgb.b=0.0; 230 | }else if(val > x3 && val <= x4){ //5 231 | rgb.r=cf1.r; 232 | rgb.g=cf1.g-color_interpolation_(xdelta1, cf1.g, val-x3); 233 | rgb.b=0.0; 234 | }else if(val > x4){ //6 235 | rgb.r=cf1.r-color_interpolation_(xdelta1, cf1.r, val-x4); 236 | rgb.g=0.0; 237 | rgb.b=0.0; 238 | } 239 | return rgb; 240 | } 241 | 242 | // Linear palette 243 | gm_rgb fl_palette::linear_palette_(double val){ 244 | double rydelta1, gydelta1, bydelta1; 245 | 246 | cf1.r=20.0; cf1.g=20.0; cf1.b=20.0; 247 | cf2.r=255.0; cf2.g=255.0; cf2.b=255.0; 248 | ydelta1 = 255.0; 249 | 250 | rydelta1 = cf2.r-cf1.r; 251 | gydelta1 = cf2.g-cf1.g; 252 | bydelta1 = cf2.b-cf1.b; 253 | if(val >= 0 && val <= x0){ // 1 254 | rgb.r=cf1.r+color_interpolation_(xdelta1, rydelta1, val); 255 | rgb.g=cf1.g+color_interpolation_(xdelta1, gydelta1, val); 256 | rgb.b=cf1.b+color_interpolation_(xdelta1, bydelta1, val); 257 | } 258 | return rgb; 259 | } 260 | 261 | 262 | 263 | /// RUBISH 264 | 265 | 266 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | # Edmanuel Torres 21/10/2004 2 | 3 | include ../makeinclude 4 | 5 | all: $(PRGS).o 6 | 7 | clean: 8 | rm -rf *o $(PRGS) -------------------------------------------------------------------------------- /test/contour.h: -------------------------------------------------------------------------------- 1 | // generated by Fast Light User Interface Designer (fluid) version 1.0300 2 | 3 | #ifndef contour_h 4 | #define contour_h 5 | #include 6 | #include 7 | #include 8 | #include 9 | extern fl_gl_contour *ct3; 10 | #include 11 | #include 12 | extern Fl_Slider *sc; 13 | extern Fl_Slider *_z; 14 | #include 15 | #include 16 | #include 17 | extern Fl_Button *button_data; 18 | extern Fl_Button *button_graph; 19 | #include 20 | extern Fl_Input *_xyz_file; 21 | #include 22 | extern Fl_Tabs *control_panel; 23 | #include 24 | extern Fl_Choice *ip; 25 | extern Fl_Choice *pt; 26 | #include 27 | extern Fl_Value_Input *gx; 28 | extern Fl_Value_Input *gy; 29 | extern Fl_Value_Input *lv; 30 | #include 31 | extern Fl_Check_Button *_bx_d; 32 | extern Fl_Check_Button *_ch_pl; 33 | extern Fl_Check_Button *_ch_d; 34 | extern Fl_Check_Button *_ch_sp; 35 | extern Fl_Check_Button *_btt_2d; 36 | extern Fl_Check_Button *_btt_3d; 37 | extern Fl_Choice *g2d; 38 | extern Fl_Choice *g3d; 39 | extern Fl_Check_Button *_chk_avg; 40 | extern Fl_Check_Button *_chk_del; 41 | extern Fl_Value_Input *_tol; 42 | extern Fl_Value_Input *gx1; 43 | extern Fl_Value_Input *gy1; 44 | extern Fl_Value_Input *gz1; 45 | extern Fl_Value_Input *gx2; 46 | extern Fl_Value_Input *gy2; 47 | extern Fl_Value_Input *gz2; 48 | extern Fl_Group *_sm_lm; 49 | extern Fl_Value_Input *cgx1; 50 | extern Fl_Value_Input *cgy1; 51 | extern Fl_Value_Input *cgx2; 52 | extern Fl_Value_Input *cgy2; 53 | extern Fl_Button *_save_as; 54 | extern Fl_Button *rs; 55 | extern Fl_Check_Button *_chk_cut; 56 | extern Fl_Check_Button *_chk_rf; 57 | extern Fl_Menu_Item menu_ip[]; 58 | extern Fl_Menu_Item menu_pt[]; 59 | extern Fl_Menu_Item menu_g2d[]; 60 | extern Fl_Menu_Item menu_g3d[]; 61 | void load_xyz_data(); 62 | void build_graph(); 63 | #endif 64 | --------------------------------------------------------------------------------