ensightPartFaces.C
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
00025
00026
00027 #include "ensightPartFaces.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "IOstreams.H"
00030 #include "IStringStream.H"
00031 #include "dictionary.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037 defineTypeNameAndDebug(ensightPartFaces, 0);
00038 addToRunTimeSelectionTable(ensightPart, ensightPartFaces, istream);
00039 }
00040
00041
00042 Foam::List<Foam::word> Foam::ensightPartFaces::elemTypes_
00043 (
00044 IStringStream
00045 (
00046 "(tria3 quad4 nsided)"
00047 )()
00048 );
00049
00050
00051
00052
00053 Foam::ensightPartFaces::ensightPartFaces
00054 (
00055 label partNumber,
00056 const string& partDescription
00057 )
00058 :
00059 ensightPart(partNumber, partDescription)
00060 {
00061 isCellData_ = false;
00062 }
00063
00064
00065 Foam::ensightPartFaces::ensightPartFaces
00066 (
00067 label partNumber,
00068 const polyMesh& pMesh,
00069 const polyPatch& pPatch
00070 )
00071 :
00072 ensightPart(partNumber, pPatch.name(), pMesh)
00073 {
00074 isCellData_ = false;
00075 offset_ = pPatch.start();
00076 size_ = pPatch.size();
00077
00078
00079 label nTri = 0;
00080 label nQuad = 0;
00081 label nPoly = 0;
00082
00083 forAll (pPatch, patchfaceI)
00084 {
00085 const face& f = pMesh.faces()[patchfaceI + offset_];
00086
00087 if (f.size() == 3)
00088 {
00089 nTri++;
00090 }
00091 else if (f.size() == 4)
00092 {
00093 nQuad++;
00094 }
00095 else
00096 {
00097 nPoly++;
00098 }
00099 }
00100
00101
00102
00103 labelList triCells(nTri);
00104 labelList quadCells(nQuad);
00105 labelList polygonCells(nPoly);
00106
00107 nTri = 0;
00108 nQuad = 0;
00109 nPoly = 0;
00110
00111
00112 forAll(pPatch, patchfaceI)
00113 {
00114 const face& f = pMesh.faces()[patchfaceI + offset_];
00115
00116 if (f.size() == 3)
00117 {
00118 triCells[nTri++] = patchfaceI;
00119 }
00120 else if (f.size() == 4)
00121 {
00122 quadCells[nQuad++] = patchfaceI;
00123 }
00124 else
00125 {
00126 polygonCells[nPoly++] = patchfaceI;
00127 }
00128 }
00129
00130
00131
00132 elemLists_.setSize(elementTypes().size());
00133
00134 elemLists_[tria3Elements].transfer( triCells );
00135 elemLists_[quad4Elements].transfer( quadCells );
00136 elemLists_[nsidedElements].transfer( polygonCells );
00137 }
00138
00139
00140 Foam::ensightPartFaces::ensightPartFaces(const ensightPartFaces &part)
00141 :
00142 ensightPart(part)
00143 {}
00144
00145
00146 Foam::ensightPartFaces::ensightPartFaces(Istream& is)
00147 :
00148 ensightPart()
00149 {
00150 isCellData_ = false;
00151 reconstruct(is);
00152 }
00153
00154
00155
00156
00157 Foam::ensightPartFaces::~ensightPartFaces()
00158 {}
00159
00160
00161
00162
00163 Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const
00164 {
00165 const polyMesh& mesh = *meshPtr_;
00166
00167 localPoints ptList(mesh);
00168 labelList& usedPoints = ptList.list;
00169 label nPoints = 0;
00170
00171 forAll(elemLists_, typeI)
00172 {
00173 const labelList& idList = elemLists_[typeI];
00174
00175
00176 forAll(idList, i)
00177 {
00178 label id = idList[i] + offset_;
00179 const face& f = mesh.faces()[id];
00180
00181 forAll(f, fp)
00182 {
00183 if (usedPoints[f[fp]] == -1)
00184 {
00185 usedPoints[f[fp]] = nPoints++;
00186 }
00187 }
00188 }
00189 }
00190
00191
00192 nPoints = 0;
00193 forAll(usedPoints, ptI)
00194 {
00195 if (usedPoints[ptI] > -1)
00196 {
00197 usedPoints[ptI] = nPoints++;
00198 }
00199 }
00200
00201 ptList.nPoints = nPoints;
00202 return ptList;
00203 }
00204
00205
00206 void Foam::ensightPartFaces::writeConnectivity
00207 (
00208 ensightGeoFile& os,
00209 const string& key,
00210 const labelList& idList,
00211 const labelList& pointMap
00212 ) const
00213 {
00214 os.writeKeyword(key);
00215 os.write(idList.size());
00216 os.newline();
00217
00218 const faceList& meshFaces = meshPtr_->faces();
00219
00220
00221 if (word(key) == "nsided")
00222 {
00223
00224 forAll(idList, i)
00225 {
00226 label id = idList[i] + offset_;
00227 const face& f = meshFaces[id];
00228
00229 os.write( f.size() );
00230 os.newline();
00231 }
00232 }
00233
00234
00235 forAll(idList, i)
00236 {
00237 label id = idList[i] + offset_;
00238 const face& f = meshFaces[id];
00239
00240
00241
00242 forAll(f, fp)
00243 {
00244 os.write( pointMap[f[fp]] + 1 );
00245 }
00246 os.newline();
00247 }
00248 }
00249
00250
00251
Copyright © 2000-2009 OpenCFD Ltd