Helpers.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MESH_HELPERS_H
00025 #define MESH_HELPERS_H
00026
00027 #include "Elements.h"
00028
00029 #include <Base/Vector3D.h>
00030
00031 namespace MeshCore {
00032
00033
00037 struct MeshExport MeshHelpPoint
00038 {
00039 inline void Set (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt);
00040
00041 inline bool operator < (const MeshHelpPoint &rclObj) const;
00042 inline bool operator == (const MeshHelpPoint &rclObj) const;
00043
00044 unsigned long Index (void) const
00045 { return _ulInd >> 2; }
00046
00047 unsigned long Corner (void) const
00048 { return _ulInd & 3; }
00049
00050 MeshPoint _clPt;
00051 unsigned long _ulInd;
00052 };
00053
00057 struct MeshPointBuilder: public std::vector<MeshHelpPoint>
00058 {
00059 inline void Add (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt);
00060 };
00061
00065 struct MeshExport MeshHelpBuilderEdge
00066 {
00067 unsigned long Side (void) const
00068 { return _ulFIndex & 3; }
00069
00070 unsigned long Index (void) const
00071 { return _ulFIndex >> 2; }
00072
00073 inline void Set (unsigned long ulInd1, unsigned long ulInd2,
00074 unsigned long ulSide, unsigned long ulFInd);
00075
00076 inline bool operator < (const MeshHelpBuilderEdge &rclObj) const;
00077
00078 inline bool operator == (const MeshHelpBuilderEdge &rclObj) const;
00079
00080
00081 inline bool operator != (const MeshHelpBuilderEdge &rclObj) const;
00082
00083 unsigned long _ulFIndex;
00084 unsigned long _aulInd[2];
00085 };
00086
00090 struct MeshEdgeBuilder: public std::vector<MeshHelpBuilderEdge>
00091 {
00092 typedef std::vector<MeshHelpBuilderEdge>::iterator _TIterator;
00093 inline void Add (unsigned long ulInd1, unsigned long ulInd2, unsigned long ulSide, unsigned long ulFInd);
00094 };
00095
00096 inline void MeshHelpPoint::Set (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt)
00097 {
00098 _ulInd = (ulFacet << 2) | ulCorner;
00099 _clPt = rclPt;
00100 };
00101
00102 inline bool MeshHelpPoint::operator < (const MeshHelpPoint &rclObj) const
00103 {
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 if (_clPt.x == rclObj._clPt.x)
00120 {
00121 if (_clPt.y == rclObj._clPt.y)
00122 return _clPt.z < rclObj._clPt.z;
00123 else
00124 return _clPt.y < rclObj._clPt.y;
00125 }
00126 else
00127 return _clPt.x < rclObj._clPt.x;
00128 }
00129
00130 inline bool MeshHelpPoint::operator == (const MeshHelpPoint &rclObj) const
00131 {
00132 return Base::DistanceP2(_clPt, rclObj._clPt) < MeshDefinitions::_fMinPointDistanceP2;
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 }
00150
00151 inline void MeshPointBuilder::Add (unsigned long ulCorner, unsigned long ulFacet, const Base::Vector3f &rclPt)
00152 {
00153 MeshHelpPoint clObj;
00154 clObj.Set(ulCorner, ulFacet, rclPt);
00155 push_back(clObj);
00156 }
00157
00158 inline void MeshHelpBuilderEdge::Set ( unsigned long ulInd1, unsigned long ulInd2,
00159 unsigned long ulSide, unsigned long ulFInd)
00160 {
00161 if (ulInd1 < ulInd2)
00162 {
00163 _aulInd[0] = ulInd1;
00164 _aulInd[1] = ulInd2;
00165 }
00166 else
00167 {
00168 _aulInd[0] = ulInd2;
00169 _aulInd[1] = ulInd1;
00170 }
00171 _ulFIndex = (ulFInd << 2) | ulSide;
00172 }
00173
00174 inline bool MeshHelpBuilderEdge::operator < (const MeshHelpBuilderEdge &rclObj) const
00175 {
00176 if (_aulInd[0] == rclObj._aulInd[0])
00177 return _aulInd[1] < rclObj._aulInd[1];
00178 else
00179 return _aulInd[0] < rclObj._aulInd[0];
00180 }
00181
00182 inline bool MeshHelpBuilderEdge::operator == (const MeshHelpBuilderEdge &rclObj) const
00183 {
00184 return (_aulInd[0] == rclObj._aulInd[0]) && (_aulInd[1] == rclObj._aulInd[1]);
00185 }
00186
00187 inline bool MeshHelpBuilderEdge::operator != (const MeshHelpBuilderEdge &rclObj) const
00188 {
00189 return (_aulInd[0] != rclObj._aulInd[0]) || (_aulInd[1] != rclObj._aulInd[1]);
00190 }
00191
00192
00193 inline void MeshEdgeBuilder::Add (unsigned long ulInd1, unsigned long ulInd2,
00194 unsigned long ulSide, unsigned long ulFInd)
00195 {
00196 MeshHelpBuilderEdge clObj;
00197 clObj.Set(ulInd1, ulInd2, ulSide, ulFInd);
00198 push_back(clObj);
00199 }
00200
00201 }
00202
00203 #endif // MESH_HELPERS_H