WRLsurfaceFormat.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 "WRLsurfaceFormat.H"
00028
00029 #include "Ostream.H"
00030 #include "OFstream.H"
00031 #include "ListOps.H"
00032
00033
00034
00035 template<class Face>
00036 Foam::fileFormats::WRLsurfaceFormat<Face>::WRLsurfaceFormat()
00037 {}
00038
00039
00040
00041
00042 template<class Face>
00043 void Foam::fileFormats::WRLsurfaceFormat<Face>::write
00044 (
00045 const fileName& filename,
00046 const MeshedSurfaceProxy<Face>& surf
00047 )
00048 {
00049 const pointField& pointLst = surf.points();
00050 const List<Face>& faceLst = surf.faces();
00051 const List<label>& faceMap = surf.faceMap();
00052
00053
00054 const List<surfZone>& zones =
00055 (
00056 surf.surfZones().size() > 1
00057 ? surf.surfZones()
00058 : oneZone(faceLst, "")
00059 );
00060
00061 const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
00062
00063 OFstream os(filename);
00064 if (!os.good())
00065 {
00066 FatalErrorIn
00067 (
00068 "fileFormats::WRLsurfaceFormat::write"
00069 "(const fileName&, const MeshedSurfaceProxy<Face>&)"
00070 )
00071 << "Cannot open file for writing " << filename
00072 << exit(FatalError);
00073 }
00074
00075 writeHeader(os, pointLst, faceLst.size(), zones);
00076
00077 os << "\n"
00078 "Group {\n"
00079 " children [\n"
00080 " Shape {\n";
00081
00082 writeAppearance(os);
00083
00084 os <<
00085 " geometry IndexedFaceSet {\n"
00086 " coord Coordinate {\n"
00087 " point [\n";
00088
00089
00090 forAll(pointLst, ptI)
00091 {
00092 const point& pt = pointLst[ptI];
00093
00094 os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
00095 }
00096
00097 os <<
00098 " ]\n"
00099 " }\n"
00100 " coordIndex [\n";
00101
00102 label faceIndex = 0;
00103 forAll(zones, zoneI)
00104 {
00105 const surfZone& zone = zones[zoneI];
00106
00107 if (useFaceMap)
00108 {
00109 forAll(zone, localFaceI)
00110 {
00111 const Face& f = faceLst[faceMap[faceIndex++]];
00112
00113 forAll(f, fp)
00114 {
00115 os << f[fp] << ' ';
00116 }
00117 os << "-1,\n";
00118 }
00119 }
00120 else
00121 {
00122 forAll(zone, localFaceI)
00123 {
00124 const Face& f = faceLst[faceIndex++];
00125
00126 forAll(f, fp)
00127 {
00128 os << ' ' << f[fp];
00129 }
00130 os << " -1,\n";
00131 }
00132 }
00133 }
00134
00135 os <<
00136 " ]\n"
00137 " }\n"
00138 " }\n"
00139 " ]\n"
00140 "}\n";
00141 }
00142
00143
00144
Copyright © 2000-2009 OpenCFD Ltd