2014-11-09 00:10:28 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
2015-05-17 13:32:07 +00:00
|
|
|
\\ / F ield | foam-extend: Open Source CFD
|
|
|
|
\\ / O peration | Version: 3.2
|
|
|
|
\\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
\\/ M anipulation | For copyright notice see file Copyright
|
2014-11-09 00:10:28 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
License
|
2015-05-17 13:32:07 +00:00
|
|
|
This file is part of foam-extend.
|
2014-11-09 00:10:28 +00:00
|
|
|
|
2015-05-17 13:32:07 +00:00
|
|
|
foam-extend is free software: you can redistribute it and/or modify it
|
2014-11-09 00:10:28 +00:00
|
|
|
under the terms of the GNU General Public License as published by the
|
2015-05-17 13:32:07 +00:00
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
2014-11-09 00:10:28 +00:00
|
|
|
option) any later version.
|
|
|
|
|
2015-05-17 13:32:07 +00:00
|
|
|
foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
2014-11-09 00:10:28 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2015-05-17 13:32:07 +00:00
|
|
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2014-11-09 00:10:28 +00:00
|
|
|
|
|
|
|
Description
|
|
|
|
cfMesh utility to convert a surface file to VTK multiblock dataset
|
|
|
|
format, including the patches, feature edges and surface features.
|
|
|
|
|
|
|
|
Author
|
|
|
|
Ivor Clifford <ivor.clifford@psi.ch>
|
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "argList.H"
|
|
|
|
#include "autoPtr.H"
|
|
|
|
#include "OFstream.H"
|
|
|
|
#include "triSurf.H"
|
|
|
|
#include "triSurfModifier.H"
|
|
|
|
#include "xmlTag.H"
|
|
|
|
|
|
|
|
using namespace Foam;
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
//- Write the supplied pointList in serial vtkPolyData format
|
|
|
|
void writePointsToVTK
|
|
|
|
(
|
|
|
|
const fileName& fn,
|
|
|
|
const string& title,
|
|
|
|
const UList<point>& points
|
|
|
|
)
|
|
|
|
{
|
|
|
|
xmlTag xmlRoot("VTKFile");
|
|
|
|
xmlRoot.addAttribute("type", "PolyData");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
|
|
|
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
|
|
|
xmlPointData.addAttribute("type", "Float32");
|
|
|
|
xmlPointData.addAttribute("NumberOfComponents", 3);
|
|
|
|
xmlPointData.addAttribute("format", "ascii");
|
|
|
|
xmlPointData << points;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
OFstream os(fn);
|
|
|
|
os << xmlRoot << endl;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
Info << "Created " << fn << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//- Write the supplied addressed pointList in serial vtkPolyData format
|
|
|
|
void writePointsToVTK
|
|
|
|
(
|
|
|
|
const fileName& fn,
|
|
|
|
const string& title,
|
|
|
|
const UList<point>& points,
|
|
|
|
unallocLabelList& addr
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// Create subaddressed points
|
|
|
|
pointField newPoints(addr.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(addr, i)
|
|
|
|
{
|
|
|
|
newPoints[i] = points[addr[i]];
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writePointsToVTK
|
|
|
|
(
|
|
|
|
fn,
|
|
|
|
title,
|
|
|
|
newPoints
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//- Write the supplied edgeList in serial vtkPolyData format
|
|
|
|
void writeEdgesToVTK
|
|
|
|
(
|
|
|
|
const fileName& fn,
|
|
|
|
const string& title,
|
|
|
|
const UList<point>& points,
|
|
|
|
const LongList<edge>& edges
|
|
|
|
)
|
|
|
|
{
|
|
|
|
labelList connectivity(edges.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(edges, edgeI)
|
|
|
|
{
|
|
|
|
connectivity[edgeI] = 2*(edgeI+1);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag xmlRoot("VTKFile");
|
|
|
|
xmlRoot.addAttribute("type", "PolyData");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
|
|
|
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
|
|
|
xmlPiece.addAttribute("NumberOfLines", edges.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
|
|
|
xmlPointData.addAttribute("type", "Float32");
|
|
|
|
xmlPointData.addAttribute("NumberOfComponents", 3);
|
|
|
|
xmlPointData.addAttribute("format", "ascii");
|
|
|
|
xmlPointData << points;
|
|
|
|
|
|
|
|
xmlTag& xmlEdges = xmlPiece.addChild("Lines");
|
|
|
|
|
|
|
|
xmlTag& xmlEdgeData = xmlEdges.addChild("DataArray");
|
|
|
|
xmlEdgeData.addAttribute("type", "Int32");
|
|
|
|
xmlEdgeData.addAttribute("Name", "connectivity");
|
|
|
|
xmlEdgeData.addAttribute("format", "ascii");
|
|
|
|
xmlEdgeData << edges;
|
|
|
|
|
|
|
|
xmlTag& xmlConnectData = xmlEdges.addChild("DataArray");
|
|
|
|
xmlConnectData.addAttribute("type", "Int32");
|
|
|
|
xmlConnectData.addAttribute("Name", "offsets");
|
|
|
|
xmlConnectData.addAttribute("format", "ascii");
|
|
|
|
xmlConnectData << connectivity;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
OFstream os(fn);
|
|
|
|
os << xmlRoot << endl;
|
|
|
|
|
|
|
|
Info << "Created " << fn << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//- Write the supplied edgeList subset in serial vtkPolyData format
|
|
|
|
void writeEdgesToVTK
|
|
|
|
(
|
|
|
|
const fileName& fn,
|
|
|
|
const string& title,
|
|
|
|
const UList<point>& points,
|
|
|
|
const LongList<edge>& edges,
|
|
|
|
const unallocLabelList& addr
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// Remove unused points and create subaddressed edges
|
|
|
|
DynamicList<point> newPoints;
|
|
|
|
labelList newPointAddr(points.size(), -1);
|
|
|
|
LongList<edge> newEdges(addr.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(addr, addrI)
|
|
|
|
{
|
|
|
|
label edgeI = addr[addrI];
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
const edge& curEdge = edges[edgeI];
|
|
|
|
edge& newEdge = newEdges[addrI];
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(curEdge, i)
|
|
|
|
{
|
|
|
|
label pointId = curEdge[i];
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
if (newPointAddr[pointId] == -1)
|
|
|
|
{
|
|
|
|
newPoints.append(points[pointId]);
|
|
|
|
newPointAddr[pointId] = newPoints.size()-1;
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
newEdge[i] = newPointAddr[pointId];
|
|
|
|
}
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writeEdgesToVTK
|
|
|
|
(
|
|
|
|
fn,
|
|
|
|
title,
|
|
|
|
newPoints,
|
|
|
|
newEdges
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//- Write the supplied facet list in serial vtkPolyData format
|
|
|
|
void writeFacetsToVTK
|
|
|
|
(
|
|
|
|
const fileName& fn,
|
|
|
|
const string& title,
|
|
|
|
const UList<point>& points,
|
|
|
|
const LongList<labelledTri>& facets
|
|
|
|
)
|
|
|
|
{
|
|
|
|
labelList connectivity(facets.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(facets, faceI)
|
|
|
|
{
|
|
|
|
connectivity[faceI] = 3*(faceI+1);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
labelList regionData(facets.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(facets, faceI)
|
|
|
|
{
|
|
|
|
regionData[faceI] = facets[faceI].region();
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag xmlRoot("VTKFile");
|
|
|
|
xmlRoot.addAttribute("type", "PolyData");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
|
|
|
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
|
|
|
xmlPiece.addAttribute("NumberOfPolys", facets.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
|
|
|
xmlPointData.addAttribute("type", "Float32");
|
|
|
|
xmlPointData.addAttribute("NumberOfComponents", 3);
|
|
|
|
xmlPointData.addAttribute("format", "ascii");
|
|
|
|
xmlPointData << points;
|
|
|
|
|
|
|
|
xmlTag& xmlPolys = xmlPiece.addChild("Polys");
|
|
|
|
|
|
|
|
xmlTag& xmlPolyDataArray = xmlPolys.addChild("DataArray");
|
|
|
|
xmlPolyDataArray.addAttribute("type", "Int32");
|
|
|
|
xmlPolyDataArray.addAttribute("Name", "connectivity");
|
|
|
|
xmlPolyDataArray.addAttribute("format", "ascii");
|
|
|
|
xmlPolyDataArray << facets;
|
|
|
|
|
|
|
|
xmlTag& xmlConnectData = xmlPolys.addChild("DataArray");
|
|
|
|
xmlConnectData.addAttribute("type", "Int32");
|
|
|
|
xmlConnectData.addAttribute("Name", "offsets");
|
|
|
|
xmlConnectData.addAttribute("format", "ascii");
|
|
|
|
xmlConnectData << connectivity;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlCellData = xmlPiece.addChild("CellData");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlCellDataArray = xmlCellData.addChild("DataArray");
|
|
|
|
xmlCellDataArray.addAttribute("type", "Int32");
|
|
|
|
xmlCellDataArray.addAttribute("Name", "region");
|
|
|
|
xmlCellDataArray.addAttribute("format", "ascii");
|
|
|
|
xmlCellDataArray << regionData;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
OFstream os(fn);
|
|
|
|
os << xmlRoot << endl;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
Info << "Created " << fn << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//- Write an addressed subset of the supplied facet list
|
|
|
|
//- in serial vtkPolyData format
|
|
|
|
void writeFacetsToVTK
|
|
|
|
(
|
|
|
|
const fileName& fn,
|
|
|
|
const string& title,
|
|
|
|
const pointField& points,
|
|
|
|
const LongList<labelledTri>& facets,
|
|
|
|
const unallocLabelList& addr
|
|
|
|
)
|
2015-05-15 13:57:39 +00:00
|
|
|
{
|
2014-11-09 00:10:28 +00:00
|
|
|
// Remove unused points and create subaddressed facets
|
|
|
|
DynamicList<point> newPoints;
|
|
|
|
labelList newPointAddr(points.size(), -1);
|
|
|
|
LongList<labelledTri> newFacets(addr.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(addr, addrI)
|
|
|
|
{
|
|
|
|
label faceI = addr[addrI];
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
const labelledTri& facet = facets[faceI];
|
|
|
|
const FixedList<label, 3>& pointIds = facet;
|
|
|
|
FixedList<label, 3> newPointIds;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(pointIds, i)
|
|
|
|
{
|
|
|
|
label pointId = pointIds[i];
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
if (newPointAddr[pointId] == -1)
|
|
|
|
{
|
|
|
|
newPoints.append(points[pointId]);
|
|
|
|
newPointAddr[pointId] = newPoints.size()-1;
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
newPointIds[i] = newPointAddr[pointId];
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
newFacets[addrI] = labelledTri
|
|
|
|
(
|
|
|
|
newPointIds[0],
|
|
|
|
newPointIds[1],
|
|
|
|
newPointIds[2],
|
|
|
|
facet.region()
|
|
|
|
);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writeFacetsToVTK
|
|
|
|
(
|
|
|
|
fn,
|
|
|
|
title,
|
|
|
|
newPoints,
|
|
|
|
newFacets
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
argList::noParallel();
|
|
|
|
argList::validArgs.clear();
|
|
|
|
|
|
|
|
argList::validArgs.append("input surface file");
|
|
|
|
argList::validArgs.append("output prefix");
|
|
|
|
argList args(argc, argv);
|
|
|
|
|
|
|
|
// Process commandline arguments
|
|
|
|
fileName inFileName(args.args()[1]);
|
|
|
|
fileName outPrefix(args.args()[2]);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Read original surface
|
|
|
|
triSurf origSurf(inFileName);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
const pointField& points = origSurf.points();
|
|
|
|
const LongList<labelledTri>& facets = origSurf.facets();
|
|
|
|
const LongList<edge>& edges = origSurf.featureEdges();
|
|
|
|
const geometricSurfacePatchList& patches = origSurf.patches();
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
label index = 0;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Create file structure for multiblock dataset
|
|
|
|
mkDir(outPrefix);
|
|
|
|
mkDir(outPrefix + "/patches");
|
|
|
|
mkDir(outPrefix + "/pointSubsets");
|
|
|
|
mkDir(outPrefix + "/edgeSubsets");
|
|
|
|
mkDir(outPrefix + "/faceSubsets");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Create VTK multiblock dataset file
|
|
|
|
xmlTag xmlRoot("VTKFile");
|
|
|
|
xmlRoot.addAttribute("type", "vtkMultiBlockDataSet");
|
|
|
|
xmlRoot.addAttribute("version", "1.0");
|
|
|
|
xmlRoot.addAttribute("byte_order", "LittleEndian");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& xmlDataSet = xmlRoot.addChild("vtkMultiBlockDataSet");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Write faces and feature edges
|
|
|
|
{
|
|
|
|
fileName fn = outPrefix / "facets.vtp";
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writeFacetsToVTK
|
|
|
|
(
|
|
|
|
outPrefix / "facets.vtp",
|
|
|
|
outPrefix,
|
|
|
|
points,
|
|
|
|
facets
|
|
|
|
);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& tag = xmlDataSet.addChild("DataSet");
|
|
|
|
tag.addAttribute("index", Foam::name(index++));
|
|
|
|
tag.addAttribute("name", "facets");
|
|
|
|
tag.addAttribute("file", fn);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
{
|
|
|
|
fileName fn = outPrefix / "featureEdges.vtp";
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writeEdgesToVTK
|
|
|
|
(
|
|
|
|
outPrefix / "featureEdges.vtp",
|
|
|
|
"featureEdges",
|
|
|
|
points,
|
|
|
|
edges
|
|
|
|
);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& tag = xmlDataSet.addChild("DataSet");
|
|
|
|
tag.addAttribute("index", Foam::name(index++));
|
|
|
|
tag.addAttribute("name", "featureEdges");
|
|
|
|
tag.addAttribute("file", fn);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Write patches
|
|
|
|
// Create patch addressing
|
|
|
|
List<DynamicList<label> > patchAddr(patches.size());
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(facets, faceI)
|
|
|
|
{
|
|
|
|
patchAddr[facets[faceI].region()].append(faceI);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
{
|
|
|
|
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
|
|
|
xmlBlock.addAttribute("index", Foam::name(index++));
|
|
|
|
xmlBlock.addAttribute("name", "patches");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(patches, patchI)
|
2015-05-15 13:57:39 +00:00
|
|
|
{
|
2014-11-09 00:10:28 +00:00
|
|
|
word patchName = patches[patchI].name();
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
fileName fn = outPrefix / "patches" / patchName + ".vtp";
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writeFacetsToVTK
|
|
|
|
(
|
|
|
|
fn,
|
|
|
|
patchName,
|
|
|
|
points,
|
|
|
|
facets,
|
|
|
|
patchAddr[patchI]
|
|
|
|
);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& tag = xmlBlock.addChild("DataSet");
|
|
|
|
tag.addAttribute("index", Foam::name(patchI));
|
|
|
|
tag.addAttribute("name", patchName);
|
|
|
|
tag.addAttribute("file", fn);
|
|
|
|
}
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Write point subsets
|
|
|
|
{
|
|
|
|
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
|
|
|
xmlBlock.addAttribute("index", Foam::name(index++));
|
|
|
|
xmlBlock.addAttribute("name", "pointSubsets");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
DynList<label> subsetIndices;
|
|
|
|
labelList subsetAddr;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
origSurf.pointSubsetIndices(subsetIndices);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(subsetIndices, id)
|
|
|
|
{
|
|
|
|
word subsetName = origSurf.pointSubsetName(id);
|
|
|
|
origSurf.pointsInSubset(id, subsetAddr);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
fileName fn = outPrefix / "pointSubsets" / subsetName + ".vtp";
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writePointsToVTK
|
|
|
|
(
|
|
|
|
fn,
|
|
|
|
subsetName,
|
|
|
|
points,
|
|
|
|
subsetAddr
|
|
|
|
);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& tag = xmlBlock.addChild("DataSet");
|
|
|
|
tag.addAttribute("index", Foam::name(id));
|
|
|
|
tag.addAttribute("name", subsetName);
|
|
|
|
tag.addAttribute("file", fn);
|
|
|
|
}
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Write edge subsets
|
|
|
|
{
|
|
|
|
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
|
|
|
xmlBlock.addAttribute("index", Foam::name(index++));
|
|
|
|
xmlBlock.addAttribute("name", "edgeSubsets");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
DynList<label> subsetIndices;
|
|
|
|
labelList subsetAddr;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
origSurf.edgeSubsetIndices(subsetIndices);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(subsetIndices, id)
|
|
|
|
{
|
|
|
|
word subsetName = origSurf.edgeSubsetName(id);
|
|
|
|
origSurf.edgesInSubset(id, subsetAddr);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
fileName fn = outPrefix / "edgeSubsets" / subsetName + ".vtp";
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writeEdgesToVTK
|
|
|
|
(
|
|
|
|
fn,
|
|
|
|
subsetName,
|
|
|
|
points,
|
|
|
|
edges,
|
|
|
|
subsetAddr
|
|
|
|
);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& tag = xmlBlock.addChild("DataSet");
|
|
|
|
tag.addAttribute("index", Foam::name(id));
|
|
|
|
tag.addAttribute("name", subsetName);
|
|
|
|
tag.addAttribute("file", fn);
|
|
|
|
}
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
// Write facet subsets
|
|
|
|
{
|
|
|
|
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
|
|
|
xmlBlock.addAttribute("index", Foam::name(index++));
|
|
|
|
xmlBlock.addAttribute("name", "faceSubsets");
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
DynList<label> subsetIndices;
|
|
|
|
labelList subsetAddr;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
origSurf.facetSubsetIndices(subsetIndices);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
forAll(subsetIndices, id)
|
2015-05-15 13:57:39 +00:00
|
|
|
{
|
2014-11-09 00:10:28 +00:00
|
|
|
word subsetName = origSurf.facetSubsetName(id);
|
|
|
|
origSurf.facetsInSubset(id, subsetAddr);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
fileName fn = outPrefix / "faceSubsets" / subsetName + ".vtp";
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
writeFacetsToVTK
|
|
|
|
(
|
|
|
|
fn,
|
|
|
|
subsetName,
|
|
|
|
points,
|
|
|
|
facets,
|
|
|
|
subsetAddr
|
|
|
|
);
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
xmlTag& tag = xmlBlock.addChild("DataSet");
|
|
|
|
tag.addAttribute("index", Foam::name(id));
|
|
|
|
tag.addAttribute("name", subsetName);
|
|
|
|
tag.addAttribute("file", fn);
|
|
|
|
}
|
2015-05-15 13:57:39 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
OFstream os(outPrefix + ".vtm");
|
|
|
|
os << xmlRoot << endl;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
Info << "Created " << outPrefix + ".vtm" << endl;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
Info << "End\n" << endl;
|
2015-05-15 13:57:39 +00:00
|
|
|
|
2014-11-09 00:10:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ************************************************************************* //
|