| 1 | /**************************************************************************** |
| 2 | * VCGLib o o * |
| 3 | * Visual and Computer Graphics Library o o * |
| 4 | * _ O _ * |
| 5 | * Copyright(C) 2004 \/)\/ * |
| 6 | * Visual Computing Lab /\/| * |
| 7 | * ISTI - Italian National Research Council | * |
| 8 | * \ * |
| 9 | * All rights reserved. * |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | * This program 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 * |
| 19 | * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * |
| 20 | * for more details. * |
| 21 | * * |
| 22 | ****************************************************************************/ |
| 23 | /**************************************************************************** |
| 24 | History |
| 25 | |
| 26 | $Log: io_mask.h,v $ |
| 27 | Revision 1.7 2007/03/12 16:40:17 tarini |
| 28 | Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. |
| 29 | |
| 30 | Revision 1.6 2006/05/21 06:58:55 cignoni |
| 31 | Added ClampMask function |
| 32 | |
| 33 | Revision 1.5 2006/01/10 13:20:42 cignoni |
| 34 | Changed ply::PlyMask to io::Mask |
| 35 | |
| 36 | Revision 1.4 2004/10/28 00:52:45 cignoni |
| 37 | Better Doxygen documentation |
| 38 | |
| 39 | Revision 1.3 2004/05/12 10:19:30 ganovelli |
| 40 | new line added at the end of file |
| 41 | |
| 42 | Revision 1.2 2004/03/09 21:26:47 cignoni |
| 43 | cr lf mismatch |
| 44 | |
| 45 | Revision 1.1 2004/03/03 15:00:51 cignoni |
| 46 | Initial commit |
| 47 | |
| 48 | ****************************************************************************/ |
| 49 | #ifndef __VCGLIB_IOTRIMESH_IO_MASK |
| 50 | #define __VCGLIB_IOTRIMESH_IO_MASK |
| 51 | |
| 52 | //#include<wrap/callback.h> |
| 53 | |
| 54 | namespace vcg { |
| 55 | namespace tri { |
| 56 | namespace io { |
| 57 | |
| 58 | /** |
| 59 | @name Load and Save in Ply format |
| 60 | */ |
| 61 | //@{ |
| 62 | |
| 63 | class Mask |
| 64 | { |
| 65 | public: |
| 66 | |
| 67 | /* |
| 68 | Bitmask for specifying what data has to be loaded or saved or it is present in a given plyfile; |
| 69 | */ |
| 70 | |
| 71 | enum { |
| 72 | IOM_NONE = 0x0000, |
| 73 | |
| 74 | IOM_VERTCOORD = 0x0001, |
| 75 | IOM_VERTFLAGS = 0x0002, |
| 76 | IOM_VERTCOLOR = 0x0004, |
| 77 | IOM_VERTQUALITY = 0x0008, |
| 78 | IOM_VERTNORMAL = 0x0010, |
| 79 | IOM_VERTTEXCOORD = 0x0020, |
| 80 | |
| 81 | IOM_FACEINDEX = 0x0040, |
| 82 | IOM_FACEFLAGS = 0x0080, |
| 83 | IOM_FACECOLOR = 0x0100, |
| 84 | IOM_FACEQUALITY = 0x0200, |
| 85 | IOM_FACENORMAL = 0x0400, |
| 86 | IOM_WEDGCOLOR = 0x0800, |
| 87 | IOM_WEDGTEXCOORD = 0x1000, |
| 88 | IOM_WEDGTEXMULTI = 0x2000, // Se ha anche l'indice di texture esplicito |
| 89 | IOM_WEDGNORMAL = 0x4000, |
| 90 | |
| 91 | IOM_CAMERA = 0x8000, |
| 92 | |
| 93 | IOM_FLAGS = IOM_VERTFLAGS + IOM_FACEFLAGS, |
| 94 | |
| 95 | IOM_ALL = 0xFFFF |
| 96 | }; |
| 97 | // |
| 98 | // |
| 99 | //static void IOMask2String( int mask, char str[] ) |
| 100 | //{ |
| 101 | // str[0] = 0; |
| 102 | // |
| 103 | // strcat(str,"V:"); |
| 104 | // if( mask & IOM_VERTFLAGS ) strcat(str,"flag,"); |
| 105 | // if( mask & IOM_VERTCOLOR ) strcat(str,"color,"); |
| 106 | // if( mask & IOM_VERTQUALITY ) strcat(str,"quality,"); |
| 107 | // if( mask & IOM_VERTTEXCOORD ) strcat(str,"texcoord,"); |
| 108 | // if( mask & IOM_VERTNORMAL ) strcat(str,"normal,"); |
| 109 | // |
| 110 | // strcat(str," F:"); |
| 111 | // if( mask & IOM_FACEFLAGS ) strcat(str,"mask,"); |
| 112 | // if( mask & IOM_FACECOLOR ) strcat(str,"color,"); |
| 113 | // if( mask & IOM_FACEQUALITY ) strcat(str,"quality,"); |
| 114 | // if( mask & IOM_FACENORMAL ) strcat(str,"normal,"); |
| 115 | // |
| 116 | // strcat(str," W:"); |
| 117 | // if( mask & IOM_WEDGCOLOR ) strcat(str,"color,"); |
| 118 | // if( mask & IOM_WEDGTEXCOORD ) strcat(str,"texcoord,"); |
| 119 | // if( mask & IOM_WEDGNORMAL ) strcat(str,"normal,"); |
| 120 | // |
| 121 | // if( mask & IOM_CAMERA ) strcat(str," camera"); |
| 122 | //} |
| 123 | template <class MeshType> |
| 124 | static void ClampMask(MeshType &m, int &mask) |
| 125 | { |
| 126 | if( (mask & IOM_FACECOLOR) && !HasPerFaceColor(m) ) mask = mask & (~IOM_FACECOLOR); |
| 127 | if( (mask & IOM_WEDGTEXCOORD) && !HasPerWedgeTexCoord(m) ) mask = mask & (~IOM_WEDGTEXCOORD); |
| 128 | if( (mask & IOM_WEDGNORMAL) && !m.HasPerWedgeNormal() ) mask = mask & (~IOM_WEDGNORMAL); |
| 129 | if( (mask & IOM_VERTCOLOR) && !m.HasPerVertexColor() ) mask = mask & (~IOM_VERTCOLOR); |
| 130 | } |
| 131 | |
| 132 | }; // end class |
| 133 | //@} |
| 134 | |
| 135 | } // end namespace tri |
| 136 | } // end namespace io |
| 137 | } // end namespace vcg |
| 138 | #endif |