Wm4UniqueVerticesTriangles.h

Go to the documentation of this file.
00001 // Wild Magic Source Code
00002 // David Eberly
00003 // http://www.geometrictools.com
00004 // Copyright (c) 1998-2007
00005 //
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Lesser General Public License as published by
00008 // the Free Software Foundation; either version 2.1 of the License, or (at
00009 // your option) any later version.  The license is available for reading at
00010 // either of the locations:
00011 //     http://www.gnu.org/copyleft/lgpl.html
00012 //     http://www.geometrictools.com/License/WildMagicLicense.pdf
00013 // The license applies to versions 0 through 4 of Wild Magic.
00014 //
00015 // Version: 4.0.0 (2006/06/28)
00016 
00017 #ifndef WM4UNIQUEVERTICESTRIANGLES_H
00018 #define WM4UNIQUEVERTICESTRIANGLES_H
00019 
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4System.h"
00022 
00023 namespace Wm4
00024 {
00025 
00026 template <int N, class Real>
00027 class UniqueVerticesTriangles
00028 {
00029 public:
00030     // Construction and destruction.  A vertex is an N-tuple of Real values,
00031     // usually starting with position and optionally followed by attributes
00032     // such as normal vector, colors, and texture coordinates.
00033     //
00034     // TO DO:  Allow the user to specify an epsilon e > 0 so that vertices V0
00035     // and V1 are considered to be the same when |V1-V0| <= e.  The current
00036     // code uses e = 0.
00037     
00038     // Triangle soup.  The input vertex array consists of triples of vertices,
00039     // each triple representing a triangle.  The array akInVertex must have
00040     // 3*iTQuantity tuples.  The caller is responsible for deleting the input
00041     // vertex array if it was dynamically allocated.  An array rakOutVertex of
00042     // riOutVQuantity unique vertices and an array aiOutIndex of
00043     // riOutTQuantity unique index triples are computed; raiOutIndex has
00044     // 3*iTQuantity elements.  The indices are relative to the array of unique
00045     // vertices and each index triple represents a triangle.  The output
00046     // arrays are dynamically allocated.  The caller is responsible for
00047     // deleting them.
00048     UniqueVerticesTriangles (int iTQuantity,
00049         const TTuple<N,Real>* akInVertex, int& riOutVQuantity,
00050         TTuple<N,Real>*& rakOutVertex, int*& raiOutIndex);
00051 
00052     // Indexed triangles.  The input vertex array consists of all vertices
00053     // referenced by the input index array.  The array akInVertex must have
00054     // iInVQuantity tuples.  The array aiInIndex must have 3*iTQuantity
00055     // elements.  The caller is responsible for deleting the input arrays if
00056     // they were dynamically allocated.  An array rakOutVertex of
00057     // riOutVQuantity unique vertices and an array aiOutIndex of iTQuantity
00058     // unique index triples are computed; raiOutIndex has 3*iTQuantity
00059     // elements.  The indices are relative to the array of unique
00060     // vertices and each index triple represents a triangle.  The output
00061     // arrays are dynamically allocated.  The caller is responsible for
00062     // deleting them.
00063     UniqueVerticesTriangles (int iInVQuantity,
00064         const TTuple<N,Real>* akInVertex, int iTQuantity,
00065         const int* aiInIndex, int& riOutVQuantity,
00066         TTuple<N,Real>*& rakOutVertex, int*& raiOutIndex);
00067 
00068     ~UniqueVerticesTriangles ();
00069 
00070     // The input vertices have indices 0 <= i < VINum.  The output vertices
00071     // have indices 0 <= j < VONum.  The construction leads to a mapping of
00072     // input indices i to output indices j.  Duplicate vertices have different
00073     // input indices but the same output index.  The following function gives
00074     // you access to the mapping.  If the input index is invalid (i < 0 or
00075     // i >= VINum), the return value is -1.
00076     int GetOutputIndexFor (int iInputIndex) const;
00077 
00078 private:
00079     void ConstructUniqueVertices (int iInVQuantity,
00080         const TTuple<N,Real>* akInVertex, int& raiOutVQuantity,
00081         TTuple<N,Real>*& rakOutVertex);
00082 
00083     int m_iInVQuantity, m_iOutVQuantity;
00084     int* m_aiInToOutMapping;
00085 };
00086 
00087 }
00088 
00089 #include "Wm4UniqueVerticesTriangles.inl"
00090 
00091 #endif

Generated on Wed Nov 23 19:01:10 2011 for FreeCAD by  doxygen 1.6.1