CmguiMeshWriter.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #ifndef CMGUIWRITER_HPP_
00030 #define CMGUIWRITER_HPP_
00031 
00032 #include "AbstractTetrahedralMeshWriter.hpp"
00033 #include "OutputFileHandler.hpp"
00034 
00038 static const char CmguiNodeFileHeader3D[] = " #Fields=1\n\
00039  1) coordinates, coordinate, rectangular cartesian, #Components=3\n\
00040    x.  Value index= 1, #Derivatives= 0\n\
00041    y.  Value index= 2, #Derivatives= 0\n\
00042    z.  Value index= 3, #Derivatives= 0\n";
00043 
00047 static const char CmguiNodeFileHeader2D[] = " #Fields=1\n\
00048  1) coordinates, coordinate, rectangular cartesian, #Components=2\n\
00049    x.  Value index= 1, #Derivatives= 0\n\
00050    y.  Value index= 2, #Derivatives= 0\n";
00051 
00052 
00056 static const char CmguiNodeFileHeader1D[] = " #Fields=1\n\
00057  1) coordinates, coordinate, rectangular cartesian, #Components=1\n\
00058    x.  Value index= 1, #Derivatives= 0\n";
00059 
00063 static const char CmguiElementFileHeader3D[] = "Shape.  Dimension=3, simplex(2;3)*simplex*simplex\n\
00064  #Scale factor sets= 0\n\
00065  #Nodes= 4\n";
00066 
00070 static const char CmguiElementFileHeader3DQuadratic[] = "Shape.  Dimension=3, simplex(2;3)*simplex*simplex\n\
00071  #Scale factor sets= 0\n\
00072  #Nodes= 10\n";
00073 
00074 
00078 static const char CmguiElementFileHeader2D[] = "Shape.  Dimension=2, simplex(2)*simplex\n\
00079  #Scale factor sets= 0\n\
00080  #Nodes= 3\n";
00081 
00085 static const char CmguiElementFileHeader2DQuadratic[] = "Shape.  Dimension=2, simplex(2)*simplex\n\
00086  #Scale factor sets= 0\n\
00087  #Nodes= 6\n";
00088  
00092 static const char CmguiElementFileHeader1D[] = "Shape.  Dimension=1, line\n\
00093  #Scale factor sets= 0\n\
00094  #Nodes= 2\n";
00095 
00099 static const char CmguiElementFileHeader1DQuadratic[] = "Shape.  Dimension=1, line\n\
00100  #Scale factor sets= 0\n\
00101  #Nodes= 3\n";
00102 
00103 
00107 static const char CmguiCoordinatesFileHeader3D[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=3\n\
00108    x.  l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\
00109      #Nodes= 4\n\
00110       1.  #Values=1\n\
00111        Value indices:     1\n\
00112        Scale factor indices:   1\n\
00113       2.  #Values=1\n\
00114        Value indices:     1\n\
00115        Scale factor indices:   2\n\
00116       3.  #Values=1\n\
00117        Value indices:     1\n\
00118        Scale factor indices:   3\n\
00119       4.  #Values=1\n\
00120        Value indices:     1\n\
00121        Scale factor indices:   4\n\
00122    y.  l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\
00123      #Nodes= 4\n\
00124       1.  #Values=1\n\
00125        Value indices:     1\n\
00126        Scale factor indices:   1\n\
00127       2.  #Values=1\n\
00128        Value indices:     1\n\
00129        Scale factor indices:   2\n\
00130       3.  #Values=1\n\
00131        Value indices:     1\n\
00132        Scale factor indices:   3\n\
00133       4.  #Values=1\n\
00134        Value indices:     1\n\
00135        Scale factor indices:   4\n\
00136    z.  l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\
00137      #Nodes= 4\n\
00138       1.  #Values=1\n\
00139        Value indices:     1\n\
00140        Scale factor indices:   1\n\
00141       2.  #Values=1\n\
00142        Value indices:     1\n\
00143        Scale factor indices:   2\n\
00144       3.  #Values=1\n\
00145        Value indices:     1\n\
00146        Scale factor indices:   3\n\
00147       4.  #Values=1\n\
00148        Value indices:     1\n\
00149        Scale factor indices:   4\n";
00150 
00151 
00155 static const char CmguiCoordinatesFileHeader3DQuadratic[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=3\n\
00156    x.  q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\
00157      #Nodes= 10\n\
00158       1.  #Values=1\n\
00159        Value indices:     1\n\
00160        Scale factor indices:   1\n\
00161       2.  #Values=1\n\
00162        Value indices:     1\n\
00163        Scale factor indices:   2\n\
00164       3.  #Values=1\n\
00165        Value indices:     1\n\
00166        Scale factor indices:   3\n\
00167       4.  #Values=1\n\
00168        Value indices:     1\n\
00169        Scale factor indices:   4\n\
00170       5.  #Values=1\n\
00171        Value indices:     1\n\
00172        Scale factor indices:   5\n\
00173       6.  #Values=1\n\
00174        Value indices:     1\n\
00175        Scale factor indices:   6\n\
00176       7.  #Values=1\n\
00177        Value indices:     1\n\
00178        Scale factor indices:   7\n\
00179       8.  #Values=1\n\
00180        Value indices:     1\n\
00181        Scale factor indices:   8\n\
00182       9.  #Values=1\n\
00183        Value indices:     1\n\
00184        Scale factor indices:   9\n\
00185       10.  #Values=1\n\
00186        Value indices:     1\n\
00187        Scale factor indices:   10\n\
00188    y.  q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\
00189      #Nodes= 10\n\
00190       1.  #Values=1\n\
00191        Value indices:     1\n\
00192        Scale factor indices:   1\n\
00193       2.  #Values=1\n\
00194        Value indices:     1\n\
00195        Scale factor indices:   2\n\
00196       3.  #Values=1\n\
00197        Value indices:     1\n\
00198        Scale factor indices:   3\n\
00199       4.  #Values=1\n\
00200        Value indices:     1\n\
00201        Scale factor indices:   4\n\
00202       5.  #Values=1\n\
00203        Value indices:     1\n\
00204        Scale factor indices:   5\n\
00205       6.  #Values=1\n\
00206        Value indices:     1\n\
00207        Scale factor indices:   6\n\
00208       7.  #Values=1\n\
00209        Value indices:     1\n\
00210        Scale factor indices:   7\n\
00211       8.  #Values=1\n\
00212        Value indices:     1\n\
00213        Scale factor indices:   8\n\
00214       9.  #Values=1\n\
00215        Value indices:     1\n\
00216        Scale factor indices:   9\n\
00217       10.  #Values=1\n\
00218        Value indices:     1\n\
00219        Scale factor indices:   10\n\
00220    z.  q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\
00221      #Nodes= 10\n\
00222       1.  #Values=1\n\
00223        Value indices:     1\n\
00224        Scale factor indices:   1\n\
00225       2.  #Values=1\n\
00226        Value indices:     1\n\
00227        Scale factor indices:   2\n\
00228       3.  #Values=1\n\
00229        Value indices:     1\n\
00230        Scale factor indices:   3\n\
00231       4.  #Values=1\n\
00232        Value indices:     1\n\
00233        Scale factor indices:   4\n\
00234       5.  #Values=1\n\
00235        Value indices:     1\n\
00236        Scale factor indices:   5\n\
00237       6.  #Values=1\n\
00238        Value indices:     1\n\
00239        Scale factor indices:   6\n\
00240       7.  #Values=1\n\
00241        Value indices:     1\n\
00242        Scale factor indices:   7\n\
00243       8.  #Values=1\n\
00244        Value indices:     1\n\
00245        Scale factor indices:   8\n\
00246       9.  #Values=1\n\
00247        Value indices:     1\n\
00248        Scale factor indices:   9\n\
00249       10.  #Values=1\n\
00250        Value indices:     1\n\
00251        Scale factor indices:   10\n";
00252 
00253 
00257 static const char CmguiCoordinatesFileHeader2D[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=2\n\
00258    x.  l.simplex(2)*l.simplex, no modify, standard node based.\n\
00259      #Nodes= 3\n\
00260       1.  #Values=1\n\
00261        Value indices:     1\n\
00262        Scale factor indices:   1\n\
00263       2.  #Values=1\n\
00264        Value indices:     1\n\
00265        Scale factor indices:   2\n\
00266       3.  #Values=1\n\
00267        Value indices:     1\n\
00268        Scale factor indices:   3\n\
00269    y.  l.simplex(2)*l.simplex, no modify, standard node based.\n\
00270      #Nodes= 3\n\
00271       1.  #Values=1\n\
00272        Value indices:     1\n\
00273        Scale factor indices:   1\n\
00274       2.  #Values=1\n\
00275        Value indices:     1\n\
00276        Scale factor indices:   2\n\
00277       3.  #Values=1\n\
00278        Value indices:     1\n\
00279        Scale factor indices:   3\n";
00280 
00281 
00286 static const char CmguiCoordinatesFileHeader2DQuadratic[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=2\n\
00287    x.  q.simplex(2)*q.simplex, no modify, standard node based.\n\
00288      #Nodes= 6\n\
00289       1.  #Values=1\n\
00290        Value indices:     1\n\
00291        Scale factor indices:   1\n\
00292       2.  #Values=1\n\
00293        Value indices:     1\n\
00294        Scale factor indices:   2\n\
00295       3.  #Values=1\n\
00296        Value indices:     1\n\
00297        Scale factor indices:   3\n\
00298       4.  #Values=1\n\
00299        Value indices:     1\n\
00300        Scale factor indices:   4\n\
00301       5.  #Values=1\n\
00302        Value indices:     1\n\
00303        Scale factor indices:   5\n\
00304       6.  #Values=1\n\
00305        Value indices:     1\n\
00306        Scale factor indices:   6\n\
00307    y.  q.simplex(2)*q.simplex, no modify, standard node based.\n\
00308      #Nodes= 6\n\
00309       1.  #Values=1\n\
00310        Value indices:     1\n\
00311        Scale factor indices:   1\n\
00312       2.  #Values=1\n\
00313        Value indices:     1\n\
00314        Scale factor indices:   2\n\
00315       3.  #Values=1\n\
00316        Value indices:     1\n\
00317        Scale factor indices:   3\n\
00318       4.  #Values=1\n\
00319        Value indices:     1\n\
00320        Scale factor indices:   4\n\
00321       5.  #Values=1\n\
00322        Value indices:     1\n\
00323        Scale factor indices:   5\n\
00324       6.  #Values=1\n\
00325        Value indices:     1\n\
00326        Scale factor indices:   6\n";
00327 
00328 
00329 
00334 static const char CmguiCoordinatesFileHeader1D[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=1\n\
00335    x.  l.Lagrange, no modify, standard node based.\n\
00336      #Nodes= 2\n\
00337       1.  #Values=1\n\
00338        Value indices:     1\n\
00339        Scale factor indices:   1\n\
00340       2.  #Values=1\n\
00341        Value indices:     1\n\
00342        Scale factor indices:   2\n";
00343 
00344 
00349 static const char CmguiCoordinatesFileHeader1DQuadratic[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=1\n\
00350    x.  q.Lagrange, no modify, standard node based.\n\
00351      #Nodes= 3\n\
00352       1.  #Values=1\n\
00353        Value indices:     1\n\
00354        Scale factor indices:   1\n\
00355       2.  #Values=1\n\
00356        Value indices:     1\n\
00357        Scale factor indices:   2\n\
00358       3.  #Values=1\n\
00359        Value indices:     1\n\
00360        Scale factor indices:   3\n";
00361 
00366 static const char CmguiAdditionalFieldHeader3D[] = " field, rectangular cartesian, #Components=1\n\
00367    x.  l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\
00368      #Nodes= 4\n\
00369       1.  #Values=1\n\
00370        Value indices:     1\n\
00371        Scale factor indices:   1\n\
00372       2.  #Values=1\n\
00373        Value indices:     1\n\
00374        Scale factor indices:   2\n\
00375       3.  #Values=1\n\
00376        Value indices:     1\n\
00377        Scale factor indices:   3\n\
00378       4.  #Values=1\n\
00379        Value indices:     1\n\
00380        Scale factor indices:   4\n";
00381 
00382 
00388 static const char CmguiAdditionalFieldHeader3DQuadratic[] = " field, rectangular cartesian, #Components=1\n\
00389    x.  q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\
00390      #Nodes= 10\n\
00391       1.  #Values=1\n\
00392        Value indices:     1\n\
00393        Scale factor indices:   1\n\
00394       2.  #Values=1\n\
00395        Value indices:     1\n\
00396        Scale factor indices:   2\n\
00397       3.  #Values=1\n\
00398        Value indices:     1\n\
00399        Scale factor indices:   3\n\
00400       4.  #Values=1\n\
00401        Value indices:     1\n\
00402        Scale factor indices:   4\n\
00403       5.  #Values=1\n\
00404        Value indices:     1\n\
00405        Scale factor indices:   5\n\
00406       6.  #Values=1\n\
00407        Value indices:     1\n\
00408        Scale factor indices:   6\n\
00409       7.  #Values=1\n\
00410        Value indices:     1\n\
00411        Scale factor indices:   7\n\
00412       8.  #Values=1\n\
00413        Value indices:     1\n\
00414        Scale factor indices:   8\n\
00415       9.  #Values=1\n\
00416        Value indices:     1\n\
00417        Scale factor indices:   9\n\
00418       10.  #Values=1\n\
00419        Value indices:     1\n\
00420        Scale factor indices:   10\n";
00421 
00426 static const char CmguiAdditionalFieldHeader2D[] = " field, rectangular cartesian, #Components=1\n\
00427    x.  l.simplex(2)*l.simplex, no modify, standard node based.\n\
00428      #Nodes= 3\n\
00429       1.  #Values=1\n\
00430        Value indices:     1\n\
00431        Scale factor indices:   1\n\
00432       2.  #Values=1\n\
00433        Value indices:     1\n\
00434        Scale factor indices:   2\n\
00435       3.  #Values=1\n\
00436        Value indices:     1\n\
00437        Scale factor indices:   3\n";
00438 
00443 static const char CmguiAdditionalFieldHeader2DQuadratic[] = " field, rectangular cartesian, #Components=1\n\
00444    x.  q.simplex(2)*q.simplex, no modify, standard node based.\n\
00445      #Nodes= 6\n\
00446       1.  #Values=1\n\
00447        Value indices:     1\n\
00448        Scale factor indices:   1\n\
00449       2.  #Values=1\n\
00450        Value indices:     1\n\
00451        Scale factor indices:   2\n\
00452       3.  #Values=1\n\
00453        Value indices:     1\n\
00454        Scale factor indices:   3\n\
00455       4.  #Values=1\n\
00456        Value indices:     1\n\
00457        Scale factor indices:   4\n\
00458       5.  #Values=1\n\
00459        Value indices:     1\n\
00460        Scale factor indices:   5\n\
00461       6.  #Values=1\n\
00462        Value indices:     1\n\
00463        Scale factor indices:   6\n";
00464 
00465 
00470 static const char CmguiAdditionalFieldHeader1D[] = " field, rectangular cartesian, #Components=1\n\
00471    x.  l.Lagrange, no modify, standard node based.\n\
00472      #Nodes= 2\n\
00473       1.  #Values=1\n\
00474        Value indices:     1\n\
00475        Scale factor indices:   1\n\
00476       2.  #Values=1\n\
00477        Value indices:     1\n\
00478        Scale factor indices:   2\n";
00479        
00484 static const char CmguiAdditionalFieldHeader1DQuadratic[] = " field, rectangular cartesian, #Components=1\n\
00485    x.  q.Lagrange, no modify, standard node based.\n\
00486      #Nodes= 2\n\
00487       1.  #Values=1\n\
00488        Value indices:     1\n\
00489        Scale factor indices:   1\n\
00490       2.  #Values=1\n\
00491        Value indices:     1\n\
00492        Scale factor indices:   2\n\
00493       3.  #Values=1\n\
00494        Value indices:     1\n\
00495        Scale factor indices:   3\n";       
00496        
00497 
00509 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00510 class CmguiMeshWriter : public AbstractTetrahedralMeshWriter<ELEMENT_DIM,SPACE_DIM>
00511 {
00512 protected:
00513 
00517     std::vector<std::string> mAdditionalFieldNames;
00518     
00519     
00524     std::vector<std::string> mRegionNames;// {tissue, bath, whatever}
00525 
00532     std::string mGroupName;
00533     
00538     std::string mElementFileHeader;
00539 
00545     std::string mCoordinatesFileHeader;
00546 
00551     std::string mAdditionalFieldHeader;
00552     
00557     unsigned mNumNodesPerElement;
00558     
00562     std::vector<unsigned> mReordering;
00563 
00570     void WriteNodeFileHeader(out_stream& rpNodeFile);
00571 
00572 public:
00573 
00581     CmguiMeshWriter(const std::string& rDirectory,
00582                     const std::string& rBaseName,
00583                     bool cleanDirectory=true);
00584 
00588     void WriteFiles();
00589 
00595     void SetAdditionalFieldNames(std::vector<std::string>& rFieldNames);
00596 
00602     void SetRegionNames(std::vector<std::string>& rRegionNames);
00603 
00607     virtual ~CmguiMeshWriter()
00608     {}
00609     
00618     static bool CompareCmguiFiles(std::string& rPath1, std::string& rPath2);
00619 };
00620 
00621 #endif /*CMGUIWRITER_HPP_*/

Generated on Mon Nov 1 12:35:24 2010 for Chaste by  doxygen 1.5.5