| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /********************************************************************** 00002 VRS - The Virtual Rendering System 00003 Copyright (C) 2001 Computer Graphics Systems Group at the 00004 Hasso-Plattner-Institute, Potsdam, Germany. 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 This library is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 See the GNU Lesser General Public License for more details. 00013 You should have received a copy of the GNU Lesser+ General Public 00014 License along with this library; if not, write to the FreeSoftware 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. 00016 **********************************************************************/ 00017 // $Id: facet.h 4633 2005-01-03 01:43:11Z klimetschek $ 00018 // $Date: 2005-01-03 02:43:11 +0100 (Mon, 03 Jan 2005) $ 00019 // $Revision: 4633 $ 00020 // $State$ 00021 // $Author: klimetschek $ 00022 // 00023 // $Log$ 00024 // Revision 1.31 2005/01/03 01:43:07 klimetschek 00025 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00026 // - removed vrs.vcproj 00027 // minor things: 00028 // - added all glutexamples to vrs4glut.sln 00029 // - fixed some problems in glutexamples 00030 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00031 // 00032 // Revision 1.30 2004/12/10 17:34:41 buchholz 00033 // comment added 00034 // 00035 // Revision 1.29 2004/11/05 13:58:09 basch 00036 // Class comment changed (Doxygen style) 00037 // 00038 // Revision 1.28 2004/03/12 16:28:38 baumann 00039 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00040 // 00041 // Revision 1.27 2004/01/19 11:43:56 baumann 00042 // serialization mechanism improved 00043 // 00044 // Revision 1.26 2004/01/15 14:16:53 baumann 00045 // serialization mechanism improved 00046 // 00047 // Revision 1.25 2003/11/07 14:19:24 kirsch 00048 // removed leading underscore from include guards 00049 // 00050 // Revision 1.24 2003/03/21 17:06:03 kirsch 00051 // changed Facet orientation to make it match VRS' left-handed coordinate system 00052 // 00053 // Revision 1.23 2002/10/11 12:43:03 kirsch 00054 // removed unneeded includes 00055 // 00056 // Revision 1.22 2002/10/11 12:12:16 kirsch 00057 // removed signed/unsigned conversion warning 00058 // 00059 // Revision 1.21 2002/07/12 08:08:18 baumann 00060 // serialization of Facet::Loop implemented 00061 // 00062 // Revision 1.20 2002/07/02 15:23:48 baumann 00063 // non-persistent containers now have the prefix NonPersistent, e.g. NonPersistentArray<T> 00064 // persistent containers now have no prefix, e.g. Array<T> 00065 // 00066 // Revision 1.19 2002/07/02 06:12:34 baumann 00067 // VRS::Iterator<T> completely rewritten 00068 // 00069 // Revision 1.18 2002/06/24 14:03:38 baumann 00070 // changed List<T> to Array<T> 00071 // 00072 // Revision 1.17 2002/05/07 14:20:16 baumann 00073 // support for edge flags improved (by Peter Grabs) 00074 // support for different winding rules added (by Peter Grabs) 00075 // 00076 // Revision 1.16 2002/04/10 10:39:18 baumann 00077 // comments fixed 00078 // 00079 // Revision 1.15 2002/03/26 15:18:43 kersting 00080 // added cahced boundingbox 00081 // 00082 // Revision 1.14 2002/03/05 12:57:32 kirsch 00083 // member variables are private now, changed category to return enum value, 00084 // fixed some very ugly programming constructs, added bug warning 00085 // 00086 // Revision 1.13 2002/03/04 11:08:34 kersting 00087 // directory structure changes 00088 // 00089 // Revision 1.12 2002/03/03 21:44:24 kosta 00090 // VRS_TYPEINFO-macro rewritten 00091 // 00092 // Revision 1.11 2002/03/03 16:37:59 kosta 00093 // changed VRS-typeinfo to C++-typeid 00094 // 00095 // Revision 1.10 2002/02/19 10:34:08 kosta 00096 // undone all changes since 2002-02-15 00097 // 00098 // Revision 1.7 2002/02/05 07:48:25 kosta 00099 // new persistency macros: 00100 // VRS_SERIALIZABLE(CLASS_NAME); 00101 // VRS_SERIALIZABLE_ABSTRACT_CLASS(CLASS_NAME); 00102 // VRS_SERIALIZABLE_NO_SO_CLASS(CLASS_NAME) 00103 // 00104 // Revision 1.6 2002/02/04 13:07:19 kosta 00105 // VRS_SERIALIZABLE macros completely rewritten 00106 // 00107 // Revision 1.5 2002/02/04 11:54:37 kosta 00108 // persistency rewritten (for better namespace support) 00109 // 00110 // Revision 1.4 2002/01/15 16:25:53 kosta 00111 // macros rewritten for a better namespace support 00112 // 00113 // Revision 1.3 2001/11/13 16:36:30 kirsch 00114 // changed line feed to unix style (removed control-M) 00115 // 00116 // Revision 1.2 2001/08/21 09:35:50 kersting 00117 // changed layout 00118 // 00119 // Revision 1.1.1.1 2001/06/08 08:09:20 kirsch 00120 // imported alpha-version by olli 00121 // 00122 00123 00124 #ifndef VRS_FACET_H 00125 #define VRS_FACET_H 00126 00127 #include <vrs/container/array.h> 00128 #include <vrs/container/iterator.h> 00129 #include <vrs/shape.h> 00130 #include <vrs/color.h> 00131 00132 namespace VRS { 00133 00146 class VRS_CORE_API Facet : public Shape { 00147 00148 00149 public: 00150 00151 enum WindingRule { 00152 FirstWindingRule, 00153 Odd, NonZero, Positive, Negative, AbsGreaterOne, 00154 LastWindingRule 00155 }; 00156 VRS_SERIALIZABLE_CLASS_ENUM(WindingRule); 00157 00158 enum EdgeFlagAttitude { 00159 FirstEdgeFlagAttitude, 00160 NoForce, ForceGeneration, ForceNoGeneration, 00161 LastEdgeFlagAttitude 00162 }; 00163 VRS_SERIALIZABLE_CLASS_ENUM(EdgeFlagAttitude); 00164 00165 Facet( 00166 Iterator<Vector>* boundaryVertices = NULL, 00167 Iterator<Vector>* boundaryNormals = NULL, 00168 Iterator<Vector>* boundaryTexture = NULL, 00169 Iterator<Color>* boundaryColors = NULL, 00170 WindingRule windingRule=Facet::Odd, 00171 EdgeFlagAttitude edgeFlagAttitude=Facet::NoForce 00172 ); 00173 00174 void setEdgeFlagAttitude(EdgeFlagAttitude edgeFlagAttitude); 00175 EdgeFlagAttitude getEdgeFlagAttitude() const; 00176 00177 void setWindingRule(WindingRule windingRule); 00178 WindingRule getWindingRule() const; 00179 00180 void insertLoop ( 00181 unsigned int position, 00182 Iterator<Vector>* vertex = NULL, 00183 Iterator<Vector>* normals = NULL, 00184 Iterator<Vector>* texture = NULL, 00185 Iterator<Color>* color = NULL 00186 ); 00187 void removeLoop(unsigned int loop); 00188 unsigned int loops () const; 00196 Iterator<Vector>* vertexLoop (unsigned int loop) const; 00197 Iterator<Vector>* normalLoop (unsigned int loop) const; 00198 Iterator<Vector>* textureLoop (unsigned int loop) const; 00199 Iterator<Color>* colorLoop (unsigned int loop) const; 00203 enum Category { 00204 NotConvex=1, NotConvexDegenerate=2, ConvexDegenerate=3, 00205 ConvexCCW=4, ConvexCW=5 00206 }; 00207 Category category() const; 00224 00225 00226 00227 Vector normal() const; 00228 00229 00230 virtual Bounds boundingBox() const; 00231 00232 virtual void modified(); 00233 00234 VRS_TYPEINFO(Facet, Shape); 00235 VRS_SERIALIZABLE(Facet); 00236 00237 private: 00238 struct VRS_CORE_API Loop { 00239 SO<Iterator<Vector> > vertex_; 00240 SO<Iterator<Vector> > normal_; 00241 SO<Iterator<Vector> > texture_; 00242 SO<Iterator<Color> > color_; 00243 00244 bool operator==(const Loop& l) { 00245 return (vertex_==l.vertex_ && normal_==l.normal_ 00246 && texture_==l.texture_ && color_==l.color_); 00247 } 00248 bool operator!=(const Loop& l) { return !operator==(l); } 00249 00250 VRS_SERIALIZABLE_NO_SO_CLASS(Loop); 00251 }; 00252 00253 SO<Array<Loop> > loops_; 00254 WindingRule windingRule_; 00255 EdgeFlagAttitude edgeFlagAttitude_; 00256 mutable Category category_; 00257 mutable bool recalculateCategory_; 00258 mutable Bounds bbox_; 00259 }; 00260 00261 } // namespace VRS 00262 00263 #endif // VRS_FACET_H