mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
fileFormats::FIREMeshWriter::binary = !args.optionFound("ascii");
|
||||
|
||||
// default: rescale from [m] to [mm]
|
||||
// Default: no rescaling
|
||||
scalar scaleFactor = 1;
|
||||
if (args.optionReadIfPresent("scale", scaleFactor))
|
||||
{
|
||||
|
||||
@ -43,8 +43,8 @@ Usage
|
||||
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees)
|
||||
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees)
|
||||
|
||||
-scale vector
|
||||
Scales the points by the given vector.
|
||||
-scale scalar|vector
|
||||
Scales the points by the given scalar or vector.
|
||||
|
||||
The any or all of the three options may be specified and are processed
|
||||
in the above order.
|
||||
@ -182,9 +182,9 @@ int main(int argc, char *argv[])
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"vector",
|
||||
"scale by the specified amount - eg, '(0.001 0.001 0.001)' for a "
|
||||
"uniform [mm] to [m] scaling"
|
||||
"scalar | vector",
|
||||
"scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
|
||||
"use either (0.001 0.001 0.001)' or simply '0.001'"
|
||||
);
|
||||
|
||||
#include "addRegionOption.H"
|
||||
@ -262,10 +262,10 @@ int main(int argc, char *argv[])
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " yaw " << v.z() << nl;
|
||||
|
||||
// Convert to radians
|
||||
// degToRad
|
||||
v *= pi/180.0;
|
||||
|
||||
quaternion R(quaternion::rotationSequence::XYZ, v);
|
||||
const quaternion R(quaternion::rotationSequence::XYZ, v);
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
@ -282,16 +282,10 @@ int main(int argc, char *argv[])
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " roll " << v.z() << nl;
|
||||
|
||||
// Convert to radians
|
||||
// degToRad
|
||||
v *= pi/180.0;
|
||||
|
||||
scalar yaw = v.x();
|
||||
scalar pitch = v.y();
|
||||
scalar roll = v.z();
|
||||
|
||||
quaternion R = quaternion(vector(0, 0, 1), yaw);
|
||||
R *= quaternion(vector(0, 1, 0), pitch);
|
||||
R *= quaternion(vector(1, 0, 0), roll);
|
||||
const quaternion R(quaternion::rotationSequence::ZYX, v);
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
@ -302,13 +296,34 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (args.optionReadIfPresent("scale", v))
|
||||
if (args.optionFound("scale"))
|
||||
{
|
||||
Info<< "Scaling points by " << v << endl;
|
||||
// Use readList to handle single or multiple values
|
||||
const List<scalar> scaling = args.optionReadList<scalar>("scale");
|
||||
|
||||
points.replace(vector::X, v.x()*points.component(vector::X));
|
||||
points.replace(vector::Y, v.y()*points.component(vector::Y));
|
||||
points.replace(vector::Z, v.z()*points.component(vector::Z));
|
||||
if (scaling.size() == 1)
|
||||
{
|
||||
Info<< "Scaling points uniformly by " << scaling[0] << nl;
|
||||
points *= scaling[0];
|
||||
}
|
||||
else if (scaling.size() == 3)
|
||||
{
|
||||
Info<< "Scaling points by ("
|
||||
<< scaling[0] << " "
|
||||
<< scaling[1] << " "
|
||||
<< scaling[2] << ")" << nl;
|
||||
|
||||
points.replace(vector::X, scaling[0]*points.component(vector::X));
|
||||
points.replace(vector::Y, scaling[1]*points.component(vector::Y));
|
||||
points.replace(vector::Z, scaling[2]*points.component(vector::Z));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError
|
||||
<< "-scale with 1 or 3 components only" << nl
|
||||
<< "given: " << args["scale"] << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
|
||||
@ -160,13 +160,59 @@ public:
|
||||
const std::string& datasetName
|
||||
);
|
||||
|
||||
//- Add names to array selection
|
||||
template<class StringType>
|
||||
static label addToArray
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const std::string& prefix,
|
||||
const UList<StringType>& names
|
||||
);
|
||||
|
||||
//- Add names to array selection
|
||||
template<class StringType>
|
||||
static label addToArray
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const UList<StringType>& names,
|
||||
const std::string& suffix = string::null
|
||||
);
|
||||
|
||||
//- Add objects of Type to array selection
|
||||
template<class Type>
|
||||
static label addToSelection
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const std::string& prefix,
|
||||
const IOobjectList& objects
|
||||
);
|
||||
|
||||
//- Add objects of Type to array selection
|
||||
template<class Type>
|
||||
static label addToSelection
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const IOobjectList& objects,
|
||||
const std::string& prefix = string::null
|
||||
const std::string& suffix = string::null
|
||||
);
|
||||
|
||||
//- Add objects of Type to array selection
|
||||
template<class Type>
|
||||
static label addToSelection
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const std::string& prefix,
|
||||
const HashTable<wordHashSet>& objects
|
||||
);
|
||||
|
||||
|
||||
//- Add objects of Type to array selection
|
||||
template<class Type>
|
||||
static label addToSelection
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const HashTable<wordHashSet>& objects,
|
||||
const std::string& suffix = string::null
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -28,29 +28,119 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class StringType>
|
||||
Foam::label Foam::foamPvCore::addToArray
|
||||
(
|
||||
vtkDataArraySelection *select,
|
||||
const std::string& prefix,
|
||||
const UList<StringType>& names
|
||||
)
|
||||
{
|
||||
if (prefix.empty())
|
||||
{
|
||||
for (const auto& name : names)
|
||||
{
|
||||
select->AddArray(name.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& name : names)
|
||||
{
|
||||
select->AddArray((prefix + name).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return names.size();
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
Foam::label Foam::foamPvCore::addToArray
|
||||
(
|
||||
vtkDataArraySelection *select,
|
||||
const UList<StringType>& names,
|
||||
const std::string& suffix
|
||||
)
|
||||
{
|
||||
if (suffix.empty())
|
||||
{
|
||||
for (const auto& name : names)
|
||||
{
|
||||
select->AddArray(name.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& name : names)
|
||||
{
|
||||
select->AddArray((name + suffix).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return names.size();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::foamPvCore::addToSelection
|
||||
(
|
||||
vtkDataArraySelection *select,
|
||||
const std::string& prefix,
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
return addToArray(select, prefix, objects.sortedNames(Type::typeName));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::foamPvCore::addToSelection
|
||||
(
|
||||
vtkDataArraySelection *select,
|
||||
const IOobjectList& objects,
|
||||
const std::string& prefix
|
||||
const std::string& suffix
|
||||
)
|
||||
{
|
||||
const wordList names = objects.sortedNames(Type::typeName);
|
||||
return addToArray(select, objects.sortedNames(Type::typeName), suffix);
|
||||
}
|
||||
|
||||
forAll(names, i)
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::foamPvCore::addToSelection
|
||||
(
|
||||
vtkDataArraySelection *select,
|
||||
const std::string& prefix,
|
||||
const HashTable<wordHashSet>& objects
|
||||
)
|
||||
{
|
||||
auto iter = objects.cfind(Type::typeName);
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
if (prefix.empty())
|
||||
{
|
||||
select->AddArray(names[i].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
select->AddArray((prefix + names[i]).c_str());
|
||||
}
|
||||
return addToArray(select, prefix, iter.object().sortedToc());
|
||||
}
|
||||
|
||||
return names.size();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::foamPvCore::addToSelection
|
||||
(
|
||||
vtkDataArraySelection *select,
|
||||
const HashTable<wordHashSet>& objects,
|
||||
const std::string& suffix
|
||||
)
|
||||
{
|
||||
auto iter = objects.cfind(Type::typeName);
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
return addToArray(select, iter.object().sortedToc(), suffix);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -155,7 +155,10 @@ class vtkPVFoam
|
||||
vtkSmartPointer<dataType> getCopy() const
|
||||
{
|
||||
auto copy = vtkSmartPointer<dataType>::New();
|
||||
copy->ShallowCopy(vtkgeom);
|
||||
if (vtkgeom)
|
||||
{
|
||||
copy->ShallowCopy(vtkgeom);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
@ -163,7 +166,10 @@ class vtkPVFoam
|
||||
void reuse()
|
||||
{
|
||||
dataset = vtkSmartPointer<dataType>::New();
|
||||
dataset->ShallowCopy(vtkgeom);
|
||||
if (vtkgeom)
|
||||
{
|
||||
dataset->ShallowCopy(vtkgeom);
|
||||
}
|
||||
}
|
||||
|
||||
//- Set the geometry and make a shallow copy to dataset
|
||||
|
||||
@ -85,11 +85,11 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames
|
||||
wordList names(zmesh.size());
|
||||
label nZone = 0;
|
||||
|
||||
forAll(zmesh, zonei)
|
||||
for (const auto& zn : zmesh)
|
||||
{
|
||||
if (!zmesh[zonei].empty())
|
||||
if (!zn.empty())
|
||||
{
|
||||
names[nZone++] = zmesh[zonei].name();
|
||||
names[nZone++] = zn.name();
|
||||
}
|
||||
}
|
||||
names.setSize(nZone);
|
||||
@ -100,8 +100,6 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames
|
||||
|
||||
Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
|
||||
{
|
||||
wordList names;
|
||||
|
||||
// mesh not loaded - read from file
|
||||
IOobject ioObj
|
||||
(
|
||||
@ -119,14 +117,17 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
|
||||
false
|
||||
);
|
||||
|
||||
wordList names;
|
||||
if (ioObj.typeHeaderOk<cellZoneMesh>(false, false))
|
||||
{
|
||||
zonesEntries zones(ioObj);
|
||||
|
||||
names.setSize(zones.size());
|
||||
forAll(zones, zonei)
|
||||
label nZone = 0;
|
||||
|
||||
for (const auto& zn : zones)
|
||||
{
|
||||
names[zonei] = zones[zonei].keyword();
|
||||
names[nZone++] = zn.keyword();
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +168,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
||||
<< " " << dbPtr_->timePath()/cloud::prefix << endl;
|
||||
}
|
||||
|
||||
// use the db directly since this might be called without a mesh,
|
||||
// Use the db directly since this might be called without a mesh,
|
||||
// but the region must get added back in
|
||||
fileName lagrangianPrefix(cloud::prefix);
|
||||
if (meshRegion_ != polyMesh::defaultRegion)
|
||||
@ -175,22 +176,23 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
||||
lagrangianPrefix = meshRegion_/cloud::prefix;
|
||||
}
|
||||
|
||||
// Search for list of lagrangian objects for this time
|
||||
fileNameList cloudDirs
|
||||
(
|
||||
readDir(dbPtr_->timePath()/lagrangianPrefix, fileName::DIRECTORY)
|
||||
);
|
||||
// List of lagrangian objects across all times
|
||||
HashSet<fileName> names;
|
||||
|
||||
for (const instant& t : dbPtr_().times())
|
||||
{
|
||||
names.insert
|
||||
(
|
||||
readDir
|
||||
(
|
||||
dbPtr_->path()/t.name()/lagrangianPrefix,
|
||||
fileName::DIRECTORY
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
rangeLagrangian_.reset(select->GetNumberOfArrays());
|
||||
forAll(cloudDirs, cloudi)
|
||||
{
|
||||
// Add cloud to GUI list
|
||||
select->AddArray
|
||||
(
|
||||
("lagrangian/" + cloudDirs[cloudi]).c_str()
|
||||
);
|
||||
++rangeLagrangian_;
|
||||
}
|
||||
rangeLagrangian_ += addToArray(select, "lagrangian/", names.sortedToc());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -257,39 +259,26 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
const polyPatch& pp = patches[patchId];
|
||||
if (pp.size())
|
||||
{
|
||||
enabledEntries.insert
|
||||
(
|
||||
"patch/" + pp.name()
|
||||
);
|
||||
enabledEntries.insert("patch/" + pp.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort group names
|
||||
Foam::sort(displayNames);
|
||||
for (const auto& name : displayNames)
|
||||
{
|
||||
select->AddArray(name.c_str());
|
||||
++rangePatches_;
|
||||
}
|
||||
Foam::sort(displayNames); // Sorted group names
|
||||
rangePatches_ += addToArray(select, displayNames);
|
||||
|
||||
// Add (non-zero) patches to the list of mesh parts
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (!reader_->GetShowGroupsOnly())
|
||||
{
|
||||
forAll(patches, patchi)
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
if (pp.size())
|
||||
{
|
||||
// Add patch to GUI list
|
||||
select->AddArray
|
||||
(
|
||||
("patch/" + pp.name()).c_str()
|
||||
);
|
||||
select->AddArray(("patch/" + pp.name()).c_str());
|
||||
++rangePatches_;
|
||||
}
|
||||
}
|
||||
@ -339,9 +328,9 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
&& patchDict.readIfPresent("inGroups", groupNames)
|
||||
)
|
||||
{
|
||||
forAll(groupNames, groupI)
|
||||
for (const auto& groupName : groupNames)
|
||||
{
|
||||
groups(groupNames[groupI]).insert(patchi);
|
||||
groups(groupName).insert(patchi);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -370,21 +359,13 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
{
|
||||
for (auto patchId : patchIDs)
|
||||
{
|
||||
enabledEntries.insert
|
||||
(
|
||||
"patch/" + names[patchId]
|
||||
);
|
||||
enabledEntries.insert("patch/" + names[patchId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort group names
|
||||
Foam::sort(displayNames);
|
||||
for (const auto& name : displayNames)
|
||||
{
|
||||
select->AddArray(name.c_str());
|
||||
++rangePatches_;
|
||||
}
|
||||
Foam::sort(displayNames); // Sorted group names
|
||||
rangePatches_ += addToArray(select, displayNames);
|
||||
|
||||
// Add (non-zero) patches to the list of mesh parts
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -396,10 +377,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
// Valid patch if nFace > 0 - add patch to GUI list
|
||||
if (sizes[patchi])
|
||||
{
|
||||
select->AddArray
|
||||
(
|
||||
("patch/" + names[patchi]).c_str()
|
||||
);
|
||||
select->AddArray(("patch/" + names[patchi]).c_str());
|
||||
++rangePatches_;
|
||||
}
|
||||
}
|
||||
@ -430,74 +408,44 @@ void Foam::vtkPVFoam::updateInfoZones
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
wordList namesLst;
|
||||
|
||||
//
|
||||
// cellZones information
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
if (meshPtr_)
|
||||
// cellZones
|
||||
{
|
||||
namesLst = getZoneNames(meshPtr_->cellZones());
|
||||
}
|
||||
else
|
||||
{
|
||||
namesLst = getZoneNames("cellZones");
|
||||
}
|
||||
|
||||
rangeCellZones_.reset(select->GetNumberOfArrays());
|
||||
forAll(namesLst, elemI)
|
||||
{
|
||||
select->AddArray
|
||||
const wordList names =
|
||||
(
|
||||
("cellZone/" + namesLst[elemI]).c_str()
|
||||
meshPtr_
|
||||
? getZoneNames(meshPtr_->cellZones())
|
||||
: getZoneNames("cellZones")
|
||||
);
|
||||
++rangeCellZones_;
|
||||
|
||||
rangeCellZones_.reset(select->GetNumberOfArrays());
|
||||
rangeCellZones_ += addToArray(select, "cellZone/", names);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// faceZones information
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
if (meshPtr_)
|
||||
// faceZones
|
||||
{
|
||||
namesLst = getZoneNames(meshPtr_->faceZones());
|
||||
}
|
||||
else
|
||||
{
|
||||
namesLst = getZoneNames("faceZones");
|
||||
}
|
||||
|
||||
rangeFaceZones_.reset(select->GetNumberOfArrays());
|
||||
forAll(namesLst, elemI)
|
||||
{
|
||||
select->AddArray
|
||||
const wordList names =
|
||||
(
|
||||
("faceZone/" + namesLst[elemI]).c_str()
|
||||
meshPtr_
|
||||
? getZoneNames(meshPtr_->faceZones())
|
||||
: getZoneNames("faceZones")
|
||||
);
|
||||
++rangeFaceZones_;
|
||||
|
||||
rangeFaceZones_.reset(select->GetNumberOfArrays());
|
||||
rangeFaceZones_ += addToArray(select, "faceZone/", names);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// pointZones information
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
if (meshPtr_)
|
||||
// pointZones
|
||||
{
|
||||
namesLst = getZoneNames(meshPtr_->pointZones());
|
||||
}
|
||||
else
|
||||
{
|
||||
namesLst = getZoneNames("pointZones");
|
||||
}
|
||||
|
||||
rangePointZones_.reset(select->GetNumberOfArrays());
|
||||
forAll(namesLst, elemI)
|
||||
{
|
||||
select->AddArray
|
||||
const wordList names =
|
||||
(
|
||||
("pointZone/" + namesLst[elemI]).c_str()
|
||||
meshPtr_
|
||||
? getZoneNames(meshPtr_->pointZones())
|
||||
: getZoneNames("pointZones")
|
||||
);
|
||||
++rangePointZones_;
|
||||
|
||||
rangePointZones_.reset(select->GetNumberOfArrays());
|
||||
rangePointZones_ += addToArray(select, "pointZone/", names);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
@ -525,14 +473,14 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
// Add names of sets. Search for last time directory with a sets
|
||||
// subdirectory. Take care not to search beyond the last mesh.
|
||||
|
||||
word facesInstance = dbPtr_().findInstance
|
||||
const word facesInstance = dbPtr_().findInstance
|
||||
(
|
||||
meshDir_,
|
||||
"faces",
|
||||
IOobject::READ_IF_PRESENT
|
||||
);
|
||||
|
||||
word setsInstance = dbPtr_().findInstance
|
||||
const word setsInstance = dbPtr_().findInstance
|
||||
(
|
||||
meshDir_/"sets",
|
||||
word::null,
|
||||
@ -540,7 +488,7 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
facesInstance
|
||||
);
|
||||
|
||||
IOobjectList objects(dbPtr_(), setsInstance, meshDir_/"sets");
|
||||
const IOobjectList objects(dbPtr_(), setsInstance, meshDir_/"sets");
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -553,24 +501,24 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
rangeCellSets_ += addToSelection<cellSet>
|
||||
(
|
||||
select,
|
||||
objects,
|
||||
"cellSet/"
|
||||
"cellSet/",
|
||||
objects
|
||||
);
|
||||
|
||||
rangeFaceSets_.reset(select->GetNumberOfArrays());
|
||||
rangeFaceSets_ += addToSelection<faceSet>
|
||||
(
|
||||
select,
|
||||
objects,
|
||||
"faceSet/"
|
||||
"faceSet/",
|
||||
objects
|
||||
);
|
||||
|
||||
rangePointSets_.reset(select->GetNumberOfArrays());
|
||||
rangePointSets_ += addToSelection<pointSet>
|
||||
(
|
||||
select,
|
||||
objects,
|
||||
"pointSet/"
|
||||
"pointSet/",
|
||||
objects
|
||||
);
|
||||
|
||||
if (debug)
|
||||
@ -594,21 +542,20 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
|
||||
HashSet<string> enabled = getSelectedArraySet(select);
|
||||
select->RemoveAllArrays();
|
||||
|
||||
// TODO - currently only get fields from ONE cloud
|
||||
// have to decide if the second set of fields get mixed in
|
||||
// or dealt with separately
|
||||
|
||||
const arrayRange& range = rangeLagrangian_;
|
||||
if (range.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add Lagrangian fields even if particles are not enabled?
|
||||
const int partId = range.start();
|
||||
const word cloudName = getReaderPartName(partId);
|
||||
// Reuse the previously determined cloud information.
|
||||
DynamicList<word> cloudNames(range.size());
|
||||
for (auto partId : range)
|
||||
{
|
||||
cloudNames.append(getReaderPartName(partId));
|
||||
}
|
||||
|
||||
// use the db directly since this might be called without a mesh,
|
||||
// Use the db directly since this might be called without a mesh,
|
||||
// but the region must get added back in
|
||||
fileName lagrangianPrefix(cloud::prefix);
|
||||
if (meshRegion_ != polyMesh::defaultRegion)
|
||||
@ -616,19 +563,37 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
|
||||
lagrangianPrefix = meshRegion_/cloud::prefix;
|
||||
}
|
||||
|
||||
IOobjectList objects
|
||||
(
|
||||
dbPtr_(),
|
||||
dbPtr_().timeName(),
|
||||
lagrangianPrefix/cloudName
|
||||
);
|
||||
// List of lagrangian fields across all clouds and all times.
|
||||
// ParaView displays "(partial)" after field names that only apply
|
||||
// to some of the clouds.
|
||||
HashTable<wordHashSet> fields;
|
||||
|
||||
addToSelection<IOField<label>>(select, objects);
|
||||
addToSelection<IOField<scalar>>(select, objects);
|
||||
addToSelection<IOField<vector>>(select, objects);
|
||||
addToSelection<IOField<sphericalTensor>>(select, objects);
|
||||
addToSelection<IOField<symmTensor>>(select, objects);
|
||||
addToSelection<IOField<tensor>>(select, objects);
|
||||
for (const instant& t : dbPtr_().times())
|
||||
{
|
||||
for (const auto& cloudName : cloudNames)
|
||||
{
|
||||
const HashTable<wordHashSet> localFields =
|
||||
IOobjectList
|
||||
(
|
||||
dbPtr_(),
|
||||
t.name(),
|
||||
lagrangianPrefix/cloudName
|
||||
).classes();
|
||||
|
||||
forAllConstIters(localFields, iter)
|
||||
{
|
||||
fields(iter.key()) |= iter.object();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Known/supported field-types
|
||||
addToSelection<IOField<label>>(select, fields);
|
||||
addToSelection<IOField<scalar>>(select, fields);
|
||||
addToSelection<IOField<vector>>(select, fields);
|
||||
addToSelection<IOField<sphericalTensor>>(select, fields);
|
||||
addToSelection<IOField<symmTensor>>(select, fields);
|
||||
addToSelection<IOField<tensor>>(select, fields);
|
||||
|
||||
// Restore the enabled selections
|
||||
setSelectedArrayEntries(select, enabled);
|
||||
|
||||
@ -71,6 +71,12 @@ int main(int argc, char *argv[])
|
||||
"mergeRegions",
|
||||
"combine regions from both surfaces"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"geometry scaling factor on input surfaces"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
@ -81,6 +87,8 @@ int main(int argc, char *argv[])
|
||||
const bool addPoint = args.optionFound("points");
|
||||
const bool mergeRegions = args.optionFound("mergeRegions");
|
||||
|
||||
const scalar scaleFactor = args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
|
||||
if (addPoint)
|
||||
{
|
||||
Info<< "Reading a surface and adding points from a file"
|
||||
@ -117,8 +125,12 @@ int main(int argc, char *argv[])
|
||||
<< "Writing : " << outFileName << nl << endl;
|
||||
}
|
||||
|
||||
const triSurface surface1(inFileName1);
|
||||
if (scaleFactor > 0)
|
||||
{
|
||||
Info<< "Scaling : " << scaleFactor << nl;
|
||||
}
|
||||
|
||||
const triSurface surface1(inFileName1, scaleFactor);
|
||||
Info<< "Surface1:" << endl;
|
||||
surface1.writeStats(Info);
|
||||
Info<< endl;
|
||||
@ -131,7 +143,7 @@ int main(int argc, char *argv[])
|
||||
if (addPoint)
|
||||
{
|
||||
IFstream pointsFile(args["points"]);
|
||||
pointField extraPoints(pointsFile);
|
||||
const pointField extraPoints(pointsFile);
|
||||
|
||||
Info<< "Additional Points:" << extraPoints.size() << endl;
|
||||
|
||||
@ -139,17 +151,16 @@ int main(int argc, char *argv[])
|
||||
label pointi = pointsAll.size();
|
||||
pointsAll.setSize(pointsAll.size() + extraPoints.size());
|
||||
|
||||
forAll(extraPoints, i)
|
||||
for (const auto& pt : extraPoints)
|
||||
{
|
||||
pointsAll[pointi++] = extraPoints[i];
|
||||
pointsAll[pointi++] = pt;
|
||||
}
|
||||
|
||||
combinedSurf = triSurface(surface1, surface1.patches(), pointsAll);
|
||||
}
|
||||
else
|
||||
{
|
||||
const triSurface surface2(inFileName2);
|
||||
|
||||
const triSurface surface2(inFileName2, scaleFactor);
|
||||
Info<< "Surface2:" << endl;
|
||||
surface2.writeStats(Info);
|
||||
Info<< endl;
|
||||
@ -165,21 +176,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
label pointi = 0;
|
||||
// Copy points1 into pointsAll
|
||||
forAll(points1, point1i)
|
||||
for (const auto& pt : points1)
|
||||
{
|
||||
pointsAll[pointi++] = points1[point1i];
|
||||
pointsAll[pointi++] = pt;
|
||||
}
|
||||
// Add surface2 points
|
||||
forAll(points2, point2i)
|
||||
for (const auto& pt : points2)
|
||||
{
|
||||
pointsAll[pointi++] = points2[point2i];
|
||||
pointsAll[pointi++] = pt;
|
||||
}
|
||||
|
||||
|
||||
label trianglei = 0;
|
||||
|
||||
|
||||
|
||||
// Determine map for both regions
|
||||
label nNewPatches = 0;
|
||||
labelList patch1Map(surface1.patches().size());
|
||||
@ -192,17 +201,17 @@ int main(int argc, char *argv[])
|
||||
forAll(surface1.patches(), i)
|
||||
{
|
||||
const word& name = surface1.patches()[i].name();
|
||||
HashTable<label>::iterator iter = nameToPatch.find(name);
|
||||
auto iter = nameToPatch.find(name);
|
||||
|
||||
label combinedi;
|
||||
if (iter == nameToPatch.end())
|
||||
if (iter.found())
|
||||
{
|
||||
combinedi = nameToPatch.size();
|
||||
nameToPatch.insert(name, combinedi);
|
||||
combinedi = iter.object();
|
||||
}
|
||||
else
|
||||
{
|
||||
combinedi = iter();
|
||||
combinedi = nameToPatch.size();
|
||||
nameToPatch.insert(name, combinedi);
|
||||
}
|
||||
patch1Map[i] = combinedi;
|
||||
}
|
||||
@ -212,17 +221,17 @@ int main(int argc, char *argv[])
|
||||
forAll(surface2.patches(), i)
|
||||
{
|
||||
const word& name = surface2.patches()[i].name();
|
||||
HashTable<label>::iterator iter = nameToPatch.find(name);
|
||||
auto iter = nameToPatch.find(name);
|
||||
|
||||
label combinedi;
|
||||
if (iter == nameToPatch.end())
|
||||
if (iter.found())
|
||||
{
|
||||
combinedi = nameToPatch.size();
|
||||
nameToPatch.insert(name, combinedi);
|
||||
combinedi = iter.object();
|
||||
}
|
||||
else
|
||||
{
|
||||
combinedi = iter();
|
||||
combinedi = nameToPatch.size();
|
||||
nameToPatch.insert(name, combinedi);
|
||||
}
|
||||
patch2Map[i] = combinedi;
|
||||
}
|
||||
@ -245,11 +254,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Copy triangles1 into trianglesAll
|
||||
forAll(surface1, facei)
|
||||
for (const labelledTri& tri : surface1)
|
||||
{
|
||||
const labelledTri& tri = surface1[facei];
|
||||
labelledTri& destTri = facesAll[trianglei++];
|
||||
|
||||
destTri.triFace::operator=(tri);
|
||||
@ -257,10 +264,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Add (renumbered) surface2 triangles
|
||||
forAll(surface2, facei)
|
||||
for (const labelledTri& tri : surface2)
|
||||
{
|
||||
const labelledTri& tri = surface2[facei];
|
||||
|
||||
labelledTri& destTri = facesAll[trianglei++];
|
||||
destTri[0] = tri[0] + points1.size();
|
||||
destTri[1] = tri[1] + points1.size();
|
||||
|
||||
@ -1517,6 +1517,12 @@ int main(int argc, char *argv[])
|
||||
argList::validArgs.append("surfaceFile1");
|
||||
argList::validArgs.append("surfaceFile2");
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"Geometry scaling factor (both surfaces)"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"surf1Baffle",
|
||||
@ -1587,6 +1593,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
// Scale factor for both surfaces:
|
||||
const scalar scaleFactor
|
||||
= args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
|
||||
const word surf1Name(args[2]);
|
||||
Info<< "Reading surface " << surf1Name << endl;
|
||||
triSurfaceMesh surf1
|
||||
@ -1599,6 +1609,11 @@ int main(int argc, char *argv[])
|
||||
runTime
|
||||
)
|
||||
);
|
||||
if (scaleFactor > 0)
|
||||
{
|
||||
Info<< "Scaling : " << scaleFactor << nl;
|
||||
surf1.scalePoints(scaleFactor);
|
||||
}
|
||||
|
||||
Info<< surf1Name << " statistics:" << endl;
|
||||
surf1.writeStats(Info);
|
||||
@ -1616,6 +1631,11 @@ int main(int argc, char *argv[])
|
||||
runTime
|
||||
)
|
||||
);
|
||||
if (scaleFactor > 0)
|
||||
{
|
||||
Info<< "Scaling : " << scaleFactor << nl;
|
||||
surf2.scalePoints(scaleFactor);
|
||||
}
|
||||
|
||||
Info<< surf2Name << " statistics:" << endl;
|
||||
surf2.writeStats(Info);
|
||||
@ -1627,7 +1647,7 @@ int main(int argc, char *argv[])
|
||||
edgeIntersections edgeCuts1;
|
||||
edgeIntersections edgeCuts2;
|
||||
|
||||
bool invertedSpace = args.optionFound("invertedSpace");
|
||||
const bool invertedSpace = args.optionFound("invertedSpace");
|
||||
|
||||
if (invertedSpace && validActions[action] == booleanSurface::DIFFERENCE)
|
||||
{
|
||||
@ -1736,9 +1756,7 @@ int main(int argc, char *argv[])
|
||||
const extendedFeatureEdgeMesh& feMesh = feMeshPtr();
|
||||
|
||||
feMesh.writeStats(Info);
|
||||
|
||||
feMesh.write();
|
||||
|
||||
feMesh.writeObj(feMesh.path()/sFeatFileName);
|
||||
|
||||
{
|
||||
|
||||
@ -60,7 +60,13 @@ int main(int argc, char *argv[])
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noClean",
|
||||
"suppress surface checking/cleanup on the input surface"
|
||||
"Suppress surface checking/cleanup on the input surface"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"Input geometry scaling factor"
|
||||
);
|
||||
argList args(argc, argv);
|
||||
|
||||
@ -77,7 +83,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
Info<< "Reading surface from " << inFileName << " ..." << nl << endl;
|
||||
triSurface surf(inFileName);
|
||||
|
||||
triSurface surf
|
||||
(
|
||||
inFileName,
|
||||
args.optionLookupOrDefault<scalar>("scale", -1)
|
||||
);
|
||||
surf.writeStats(Info);
|
||||
|
||||
if (!args.optionFound("noClean"))
|
||||
@ -90,7 +101,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (true)
|
||||
{
|
||||
label nEdgeCollapse = collapseEdge(surf, minLen);
|
||||
const label nEdgeCollapse = collapseEdge(surf, minLen);
|
||||
|
||||
if (nEdgeCollapse == 0)
|
||||
{
|
||||
@ -99,7 +110,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
label nSplitEdge = collapseBase(surf, minLen, minQuality);
|
||||
const label nSplitEdge = collapseBase(surf, minLen, minQuality);
|
||||
|
||||
if (nSplitEdge == 0)
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ Group
|
||||
grpSurfaceUtilities
|
||||
|
||||
Description
|
||||
Surface coarsening using `bunnylod'
|
||||
Surface coarsening using 'bunnylod'
|
||||
|
||||
Reference:
|
||||
\verbatim
|
||||
@ -75,6 +75,13 @@ int main(int argc, char *argv[])
|
||||
argList::validArgs.append("surfaceFile");
|
||||
argList::validArgs.append("reductionFactor");
|
||||
argList::validArgs.append("output surfaceFile");
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"input geometry scaling factor"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
const fileName inFileName = args[1];
|
||||
@ -90,40 +97,39 @@ int main(int argc, char *argv[])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< "Input surface :" << inFileName << endl
|
||||
<< "Reduction factor:" << reduction << endl
|
||||
<< "Output surface :" << outFileName << endl << endl;
|
||||
const scalar scaleFactor = args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
|
||||
const triSurface surf(inFileName);
|
||||
Info<< "Input surface :" << inFileName << nl
|
||||
<< "Scaling factor :" << scaleFactor << nl
|
||||
<< "Reduction factor:" << reduction << nl
|
||||
<< "Output surface :" << outFileName << nl
|
||||
<< endl;
|
||||
|
||||
const triSurface surf(inFileName, scaleFactor);
|
||||
|
||||
Info<< "Surface:" << endl;
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
|
||||
::List< ::Vector> vert; // global list of vertices
|
||||
::List< ::tridata> tri; // global list of triangles
|
||||
::List<::Vector> vert; // global list of vertices
|
||||
::List<::tridata> tri; // global list of triangles
|
||||
|
||||
|
||||
// Convert triSurface to progmesh format. Note: can use global point
|
||||
// numbering since surface read in from file.
|
||||
const pointField& pts = surf.points();
|
||||
|
||||
forAll(pts, ptI)
|
||||
for (const point& pt : pts)
|
||||
{
|
||||
const point& pt = pts[ptI];
|
||||
|
||||
vert.Add( ::Vector(pt.x(), pt.y(), pt.z()));
|
||||
vert.Add(::Vector(pt.x(), pt.y(), pt.z()));
|
||||
}
|
||||
|
||||
forAll(surf, facei)
|
||||
for (const labelledTri& f : surf)
|
||||
{
|
||||
const labelledTri& f = surf[facei];
|
||||
|
||||
tridata td;
|
||||
td.v[0]=f[0];
|
||||
td.v[1]=f[1];
|
||||
td.v[2]=f[2];
|
||||
td.v[0] = f[0];
|
||||
td.v[1] = f[1];
|
||||
td.v[2] = f[2];
|
||||
tri.Add(td);
|
||||
}
|
||||
|
||||
@ -133,20 +139,20 @@ int main(int argc, char *argv[])
|
||||
::ProgressiveMesh(vert,tri,collapse_map,permutation);
|
||||
|
||||
// rearrange the vertex list
|
||||
::List< ::Vector> temp_list;
|
||||
for (int i=0;i<vert.num;i++)
|
||||
::List<::Vector> temp_list;
|
||||
for (int i=0; i<vert.num; i++)
|
||||
{
|
||||
temp_list.Add(vert[i]);
|
||||
}
|
||||
for (int i=0;i<vert.num;i++)
|
||||
for (int i=0; i<vert.num; i++)
|
||||
{
|
||||
vert[permutation[i]]=temp_list[i];
|
||||
vert[permutation[i]] = temp_list[i];
|
||||
}
|
||||
|
||||
// update the changes in the entries in the triangle list
|
||||
for (int i=0;i<tri.num;i++)
|
||||
for (int i=0; i<tri.num; i++)
|
||||
{
|
||||
for (int j=0;j<3;j++)
|
||||
for (int j=0; j<3; j++)
|
||||
{
|
||||
tri[i].v[j] = permutation[tri[i].v[j]];
|
||||
}
|
||||
|
||||
@ -74,24 +74,24 @@ int main(int argc, char *argv[])
|
||||
argList::addBoolOption
|
||||
(
|
||||
"clean",
|
||||
"perform some surface checking/cleanup on the input surface"
|
||||
"Perform some surface checking/cleanup on the input surface"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"group",
|
||||
"reorder faces into groups; one per region"
|
||||
"Reorder faces into groups; one per region"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"geometry scaling factor - default is 1"
|
||||
"Input geometry scaling factor"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"writePrecision",
|
||||
"label",
|
||||
"write to output with the specified precision"
|
||||
"Write to output with the specified precision"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
@ -116,8 +116,10 @@ int main(int argc, char *argv[])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const scalar scaleFactor = args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
|
||||
Info<< "Reading : " << importName << endl;
|
||||
triSurface surf(importName);
|
||||
triSurface surf(importName, scaleFactor);
|
||||
|
||||
Info<< "Read surface:" << endl;
|
||||
surf.writeStats(Info);
|
||||
@ -144,13 +146,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
Info<< "writing " << exportName;
|
||||
|
||||
scalar scaleFactor = 0;
|
||||
if (args.optionReadIfPresent("scale", scaleFactor) && scaleFactor > 0)
|
||||
{
|
||||
Info<< " with scaling " << scaleFactor;
|
||||
surf.scalePoints(scaleFactor);
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
surf.write(exportName, sortByRegion);
|
||||
|
||||
@ -339,8 +339,15 @@ int main(int argc, char *argv[])
|
||||
<< " writeObj=" << writeObj
|
||||
<< " writeVTK=" << writeVTK << nl;
|
||||
|
||||
scalar scaleFactor = -1;
|
||||
// Allow rescaling of the surface points (eg, mm -> m)
|
||||
if (surfaceDict.readIfPresent("scale", scaleFactor) && scaleFactor > 0)
|
||||
{
|
||||
Info<<"Scaling : " << scaleFactor << nl;
|
||||
}
|
||||
|
||||
// Load a single file, or load and combine multiple selected files
|
||||
autoPtr<triSurface> surfPtr = loader.load(loadingOption);
|
||||
autoPtr<triSurface> surfPtr = loader.load(loadingOption, scaleFactor);
|
||||
if (!surfPtr.valid() || surfPtr().empty())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
|
||||
@ -50,6 +50,9 @@ outputName1
|
||||
|
||||
surfaces (surface1.stl surface2.nas);
|
||||
|
||||
// mm -> m scaling
|
||||
// scale 0.001;
|
||||
|
||||
// Generate additional intersection features (none | self | region)
|
||||
intersectionMethod self;
|
||||
|
||||
|
||||
@ -123,9 +123,8 @@ int main(int argc, char *argv[])
|
||||
Info<< " " << points[f[fp]] << "\n";
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
Info<< nl
|
||||
<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
||||
vector refPt = Zero;
|
||||
bool calcAroundRefPt = args.optionReadIfPresent("referencePoint", refPt);
|
||||
|
||||
triSurface surf(surfFileName);
|
||||
const triSurface surf(surfFileName);
|
||||
|
||||
scalar m = 0.0;
|
||||
vector cM = Zero;
|
||||
|
||||
@ -44,7 +44,7 @@ Usage
|
||||
Specify a feature angle
|
||||
|
||||
|
||||
E.g. inflate surface by 2cm with 1.5 safety factor:
|
||||
E.g. inflate surface by 20mm with 1.5 safety factor:
|
||||
surfaceInflate DTC-scaled.obj 0.02 1.5 -featureAngle 45 -nSmooth 2
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
surfaceMeshConvertTesting.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/surfaceMeshConvertTesting
|
||||
@ -1,5 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lsurfMesh
|
||||
@ -1,608 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
surfaceMeshConvertTesting
|
||||
|
||||
Group
|
||||
grpSurfaceUtilities
|
||||
|
||||
Description
|
||||
Converts from one surface mesh format to another, but primarily
|
||||
used for testing functionality.
|
||||
|
||||
Usage
|
||||
\b surfaceMeshConvertTesting inputFile outputFile [OPTION]
|
||||
|
||||
Options:
|
||||
- \par -clean
|
||||
Perform some surface checking/cleanup on the input surface
|
||||
|
||||
- \par -orient
|
||||
Check face orientation on the input surface
|
||||
|
||||
- \par -testModify
|
||||
Test modification mechanism
|
||||
|
||||
- \par -scale \<scale\>
|
||||
Specify a scaling factor for writing the files
|
||||
|
||||
- \par -triSurface
|
||||
Use triSurface library for input/output
|
||||
|
||||
- \par -keyed
|
||||
Use keyedSurface for input/output
|
||||
|
||||
Note
|
||||
The filename extensions are used to determine the file format type.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "triSurface.H"
|
||||
#include "surfMesh.H"
|
||||
#include "surfFields.H"
|
||||
#include "surfPointFields.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "ModifiableMeshedSurface.H"
|
||||
#include "UnsortedMeshedSurfaces.H"
|
||||
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"convert between surface formats, "
|
||||
"but primarily for testing functionality\n"
|
||||
"Normally use surfaceMeshConvert instead."
|
||||
);
|
||||
|
||||
argList::noParallel();
|
||||
argList::validArgs.append("inputFile");
|
||||
argList::validArgs.append("outputFile");
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"clean",
|
||||
"perform some surface checking/cleanup on the input surface"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"orient",
|
||||
"check surface orientation"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"testModify",
|
||||
"Test modification mechanism (MeshedSurface)"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"surfMesh",
|
||||
"test surfMesh output"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"triSurface",
|
||||
"use triSurface for read/write"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"unsorted",
|
||||
"use UnsortedMeshedSurface instead of MeshedSurface, "
|
||||
"or unsorted output (with -triSurface option)"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"triFace",
|
||||
"use triFace instead of face"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"stdout",
|
||||
"ignore output filename and write to stdout"
|
||||
);
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"geometry scaling factor - default is 1"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool optStdout = args.optionFound("stdout");
|
||||
const scalar scaleFactor = args.optionLookupOrDefault("scale", 0.0);
|
||||
|
||||
const fileName importName = args[1];
|
||||
const fileName exportName = optStdout ? "-stdout" : args[2];
|
||||
|
||||
if (importName == exportName)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Output file " << exportName << " would overwrite input file."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
!args.optionFound("triSurface")
|
||||
&&
|
||||
(
|
||||
!MeshedSurface<face>::canRead(importName, true)
|
||||
||
|
||||
(
|
||||
!optStdout
|
||||
&& !MeshedSurface<face>::canWriteType(exportName.ext(), true)
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args.optionFound("triSurface"))
|
||||
{
|
||||
triSurface surf(importName);
|
||||
|
||||
Info<< "Read surface:" << endl;
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
|
||||
// check: output to ostream, construct from istream
|
||||
{
|
||||
OStringStream os;
|
||||
os << surf;
|
||||
IStringStream is(os.str());
|
||||
|
||||
// both work:
|
||||
triSurface surf2(is);
|
||||
|
||||
// OR
|
||||
// is.rewind();
|
||||
// triSurface surf2;
|
||||
// is >> surf2;
|
||||
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "writing " << exportName;
|
||||
if (scaleFactor <= 0)
|
||||
{
|
||||
Info<< " without scaling" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " with scaling " << scaleFactor << endl;
|
||||
surf.scalePoints(scaleFactor);
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (optStdout)
|
||||
{
|
||||
Info<< surf;
|
||||
}
|
||||
else
|
||||
{
|
||||
// normally write sorted (looks nicer)
|
||||
surf.write(exportName, !args.optionFound("unsorted"));
|
||||
}
|
||||
}
|
||||
else if (args.optionFound("unsorted"))
|
||||
{
|
||||
UnsortedMeshedSurface<face> surf(importName);
|
||||
|
||||
Info<< "Read surface:" << endl;
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
|
||||
// check: output to ostream, construct from istream
|
||||
{
|
||||
OStringStream os;
|
||||
os << surf;
|
||||
IStringStream is(os.str());
|
||||
|
||||
// both work:
|
||||
UnsortedMeshedSurface<face> surf2(is);
|
||||
|
||||
// OR
|
||||
// is.rewind();
|
||||
// UnsortedMeshedSurface<face> surf2;
|
||||
// is >> surf2;
|
||||
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "writing " << exportName;
|
||||
if (scaleFactor <= 0)
|
||||
{
|
||||
Info<< " without scaling" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " with scaling " << scaleFactor << endl;
|
||||
surf.scalePoints(scaleFactor);
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (optStdout)
|
||||
{
|
||||
Info<< surf;
|
||||
}
|
||||
else
|
||||
{
|
||||
surf.write(exportName);
|
||||
}
|
||||
}
|
||||
else if (args.optionFound("triFace"))
|
||||
{
|
||||
MeshedSurface<triFace> surf(importName);
|
||||
|
||||
Info<< "Read surface:" << endl;
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
|
||||
// check: output to ostream, construct from istream
|
||||
{
|
||||
OStringStream os;
|
||||
os << surf;
|
||||
IStringStream is(os.str());
|
||||
|
||||
// both work:
|
||||
MeshedSurface<face> surf2(is);
|
||||
|
||||
// OR
|
||||
// is.rewind();
|
||||
// MeshedSurface<face> surf2;
|
||||
// is >> surf2;
|
||||
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "writing " << exportName;
|
||||
if (scaleFactor <= 0)
|
||||
{
|
||||
Info<< " without scaling" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " with scaling " << scaleFactor << endl;
|
||||
surf.scalePoints(scaleFactor);
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (optStdout)
|
||||
{
|
||||
Info<< surf;
|
||||
}
|
||||
else
|
||||
{
|
||||
surf.write(exportName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MeshedSurface<face> surf(importName);
|
||||
|
||||
Info<< "Read surface:" << endl;
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
|
||||
// check: output to ostream, construct from istream
|
||||
{
|
||||
OStringStream os;
|
||||
os << surf;
|
||||
IStringStream is(os.str());
|
||||
|
||||
// both work:
|
||||
MeshedSurface<face> surf2(is);
|
||||
|
||||
// OR
|
||||
// is.rewind();
|
||||
// MeshedSurface<face> surf2;
|
||||
// is >> surf2;
|
||||
|
||||
// surf2.read(is); // FAIL: private method
|
||||
}
|
||||
|
||||
if (args.optionFound("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
surf.cleanup(true);
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.optionFound("testModify"))
|
||||
{
|
||||
Info<< "Use ModifiableMeshedSurface to shift (1, 0, 0)" << endl;
|
||||
Info<< "original" << nl;
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
ModifiableMeshedSurface<face> tsurf(surf.xfer());
|
||||
// ModifiableMeshedSurface<face> tsurf;
|
||||
// tsurf.reset(surf.xfer());
|
||||
|
||||
Info<< "in-progress" << nl;
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
tsurf.storedPoints() += vector(1, 0, 0);
|
||||
|
||||
surf.transfer(tsurf);
|
||||
|
||||
Info<< "updated" << nl;
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
Info<< "modifier" << nl;
|
||||
tsurf.writeStats(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "writing " << exportName;
|
||||
if (scaleFactor <= 0)
|
||||
{
|
||||
Info<< " without scaling" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " with scaling " << scaleFactor << endl;
|
||||
surf.scalePoints(scaleFactor);
|
||||
surf.writeStats(Info);
|
||||
Info<< "Area : " << sum(surf.magSf()) << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (optStdout)
|
||||
{
|
||||
Info<< surf;
|
||||
}
|
||||
else
|
||||
{
|
||||
surf.write(exportName);
|
||||
}
|
||||
|
||||
if (args.optionFound("surfMesh"))
|
||||
{
|
||||
Foam::Time runTime
|
||||
(
|
||||
args.rootPath(),
|
||||
args.caseName()
|
||||
);
|
||||
|
||||
// start with "constant"
|
||||
runTime.setTime(instant(0, runTime.constant()), 0);
|
||||
|
||||
Info<< "runTime.instance() = " << runTime.instance() << endl;
|
||||
Info<< "runTime.timeName() = " << runTime.timeName() << endl;
|
||||
|
||||
Info<< "write MeshedSurface 'yetAnother' via proxy as surfMesh"
|
||||
<< endl;
|
||||
surf.write
|
||||
(
|
||||
runTime,
|
||||
"yetAnother"
|
||||
);
|
||||
|
||||
surfMesh surfIn
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"default",
|
||||
runTime.timeName(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
MeshedSurface<face> surfIn2(runTime, "foobar");
|
||||
|
||||
Info<<"surfIn2 = " << surfIn2.size() << endl;
|
||||
Info<< "surfIn = " << surfIn.size() << endl;
|
||||
|
||||
Info<< "writing surfMesh as obj = oldSurfIn.obj" << endl;
|
||||
surfIn.write("oldSurfIn.obj");
|
||||
|
||||
Info<< "runTime.instance() = " << runTime.instance() << endl;
|
||||
|
||||
surfMesh surfOut
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"mySurf",
|
||||
runTime.instance(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
surf.xfer()
|
||||
);
|
||||
|
||||
Info<< "writing surfMesh as well: " << surfOut.objectPath() << endl;
|
||||
surfOut.write();
|
||||
|
||||
surfLabelField zoneIds
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"zoneIds",
|
||||
surfOut.instance(),
|
||||
surfOut,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surfOut,
|
||||
dimless
|
||||
);
|
||||
|
||||
Info<<" surf name= " << surfOut.name() <<nl;
|
||||
Info<< "rename to anotherSurf" << endl;
|
||||
surfOut.rename("anotherSurf");
|
||||
|
||||
Info<<" surf name= " << surfOut.name() <<nl;
|
||||
|
||||
// advance time to 1
|
||||
runTime.setTime(instant(1), 1);
|
||||
surfOut.setInstance(runTime.timeName());
|
||||
|
||||
|
||||
|
||||
Info<< "writing surfMesh again well: " << surfOut.objectPath()
|
||||
<< endl;
|
||||
surfOut.write();
|
||||
|
||||
// write directly
|
||||
surfOut.write("someName.ofs");
|
||||
|
||||
#if 1
|
||||
const surfZoneList& zones = surfOut.surfZones();
|
||||
forAll(zones, zoneI)
|
||||
{
|
||||
SubList<label>
|
||||
(
|
||||
zoneIds,
|
||||
zones[zoneI].size(),
|
||||
zones[zoneI].start()
|
||||
) = zoneI;
|
||||
}
|
||||
|
||||
Info<< "write zoneIds (for testing only): "
|
||||
<< zoneIds.objectPath() << endl;
|
||||
zoneIds.write();
|
||||
|
||||
surfPointLabelField pointIds
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"zoneIds.",
|
||||
// "pointIds",
|
||||
surfOut.instance(),
|
||||
// "pointFields",
|
||||
surfOut,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surfOut,
|
||||
dimless
|
||||
);
|
||||
|
||||
forAll(pointIds, i)
|
||||
{
|
||||
pointIds[i] = i;
|
||||
}
|
||||
|
||||
Info<< "write pointIds (for testing only): "
|
||||
<< pointIds.objectPath() << endl;
|
||||
pointIds.write();
|
||||
|
||||
Info<<"surfMesh with these names: " << surfOut.names() << endl;
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -87,7 +87,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"geometry scaling factor - default is 1"
|
||||
"input geometry scaling factor"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
@ -119,10 +119,10 @@ int main(int argc, char *argv[])
|
||||
// use UnsortedMeshedSurface, not MeshedSurface to maintain ordering
|
||||
UnsortedMeshedSurface<face> surf(importName);
|
||||
|
||||
scalar scaling = 0;
|
||||
if (args.optionReadIfPresent("scale", scaling) && scaling > 0)
|
||||
const scalar scaling = args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
if (scaling > 0)
|
||||
{
|
||||
Info<< " -scale " << scaling << endl;
|
||||
Info<< " -scale " << scaling << nl;
|
||||
surf.scalePoints(scaling);
|
||||
}
|
||||
|
||||
|
||||
@ -63,6 +63,12 @@ int main(int argc, char *argv[])
|
||||
"usePierceTest",
|
||||
"determine orientation by counting number of intersections"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"input geometry scaling factor"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
@ -86,11 +92,14 @@ int main(int argc, char *argv[])
|
||||
Info<< "outside" << endl;
|
||||
}
|
||||
|
||||
|
||||
const scalar scaling = args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
if (scaling > 0)
|
||||
{
|
||||
Info<< "Input scaling: " << scaling << nl;
|
||||
}
|
||||
|
||||
// Load surface
|
||||
triSurface surf(surfFileName);
|
||||
|
||||
triSurface surf(surfFileName, scaling);
|
||||
|
||||
bool anyFlipped = false;
|
||||
|
||||
@ -118,11 +127,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (anyFlipped)
|
||||
{
|
||||
Info<< "Flipped orientation of (part of) surface." << endl;
|
||||
Info<< "Flipped orientation of (part of) surface." << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Did not flip orientation of any triangle of surface." << endl;
|
||||
Info<< "Did not flip orientation of any triangle of surface." << nl;
|
||||
}
|
||||
|
||||
Info<< "Writing new surface to " << outFileName << endl;
|
||||
|
||||
@ -46,31 +46,47 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Merge points on surface if they are within absolute distance [m]."
|
||||
);
|
||||
argList::noParallel();
|
||||
argList::validArgs.append("surfaceFile");
|
||||
argList::validArgs.append("merge distance");
|
||||
argList::validArgs.append("output surfaceFile");
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"factor",
|
||||
"input geometry scaling factor"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
const fileName surfFileName = args[1];
|
||||
const scalar mergeTol = args.argRead<scalar>(2);
|
||||
const fileName outFileName = args[3];
|
||||
|
||||
Info<< "Reading surface from " << surfFileName << " ..." << endl;
|
||||
Info<< "Merging points within " << mergeTol << " metre." << endl;
|
||||
const scalar scaling = args.optionLookupOrDefault<scalar>("scale", -1);
|
||||
|
||||
triSurface surf1(surfFileName);
|
||||
Info<< "Reading surface from " << surfFileName << " ..." << nl
|
||||
<< "Merging points within " << mergeTol << " metre." << nl;
|
||||
if (scaling > 0)
|
||||
{
|
||||
Info<< "input scaling " << scaling << nl;
|
||||
}
|
||||
|
||||
Info<< "Original surface:" << endl;
|
||||
const triSurface surf1(surfFileName, scaling);
|
||||
|
||||
Info<< "Original surface:" << nl;
|
||||
surf1.writeStats(Info);
|
||||
|
||||
|
||||
triSurface cleanSurf(surf1);
|
||||
|
||||
while (true)
|
||||
{
|
||||
label nOldVert = cleanSurf.nPoints();
|
||||
const label nOldVert = cleanSurf.nPoints();
|
||||
|
||||
cleanSurf = triSurfaceTools::mergePoints(cleanSurf, mergeTol);
|
||||
|
||||
|
||||
@ -105,7 +105,8 @@ int main(int argc, char *argv[])
|
||||
argList::addNote
|
||||
(
|
||||
"Redistribute a triSurface. "
|
||||
"The specified surface must be located in the constant/triSurface directory"
|
||||
"The specified surface must be located in the constant/triSurface "
|
||||
"directory"
|
||||
);
|
||||
|
||||
argList::validArgs.append("triSurfaceMesh");
|
||||
|
||||
@ -85,9 +85,9 @@ int main(int argc, char *argv[])
|
||||
argList::addOption
|
||||
(
|
||||
"scale",
|
||||
"vector",
|
||||
"scale by the specified amount - eg, '(0.001 0.001 0.001)' for a "
|
||||
"uniform [mm] to [m] scaling"
|
||||
"scalar | vector",
|
||||
"scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
|
||||
"use either (0.001 0.001 0.001)' or simply '0.001'"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
|
||||
n1n2[0] /= mag(n1n2[0]);
|
||||
n1n2[1] /= mag(n1n2[1]);
|
||||
|
||||
tensor T = rotationTensor(n1n2[0], n1n2[1]);
|
||||
const tensor T = rotationTensor(n1n2[0], n1n2[1]);
|
||||
|
||||
Info<< "Rotating points by " << T << endl;
|
||||
|
||||
@ -151,10 +151,10 @@ int main(int argc, char *argv[])
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " yaw " << v.z() << nl;
|
||||
|
||||
// Convert to radians
|
||||
// degToRad
|
||||
v *= pi/180.0;
|
||||
|
||||
quaternion R(quaternion::rotationSequence::XYZ, v);
|
||||
const quaternion R(quaternion::rotationSequence::XYZ, v);
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
@ -166,29 +166,43 @@ int main(int argc, char *argv[])
|
||||
<< " pitch " << v.y() << nl
|
||||
<< " roll " << v.z() << nl;
|
||||
|
||||
|
||||
// Convert to radians
|
||||
// degToRad
|
||||
v *= pi/180.0;
|
||||
|
||||
scalar yaw = v.x();
|
||||
scalar pitch = v.y();
|
||||
scalar roll = v.z();
|
||||
|
||||
quaternion R = quaternion(vector(0, 0, 1), yaw);
|
||||
R *= quaternion(vector(0, 1, 0), pitch);
|
||||
R *= quaternion(vector(1, 0, 0), roll);
|
||||
const quaternion R(quaternion::rotationSequence::ZYX, v);
|
||||
|
||||
Info<< "Rotating points by quaternion " << R << endl;
|
||||
points = transform(R, points);
|
||||
}
|
||||
|
||||
if (args.optionReadIfPresent("scale", v))
|
||||
if (args.optionFound("scale"))
|
||||
{
|
||||
Info<< "Scaling points by " << v << endl;
|
||||
// Use readList to handle single or multiple values
|
||||
const List<scalar> scaling = args.optionReadList<scalar>("scale");
|
||||
|
||||
points.replace(vector::X, v.x()*points.component(vector::X));
|
||||
points.replace(vector::Y, v.y()*points.component(vector::Y));
|
||||
points.replace(vector::Z, v.z()*points.component(vector::Z));
|
||||
if (scaling.size() == 1)
|
||||
{
|
||||
Info<< "Scaling points uniformly by " << scaling[0] << nl;
|
||||
points *= scaling[0];
|
||||
}
|
||||
else if (scaling.size() == 3)
|
||||
{
|
||||
Info<< "Scaling points by ("
|
||||
<< scaling[0] << " "
|
||||
<< scaling[1] << " "
|
||||
<< scaling[2] << ")" << nl;
|
||||
|
||||
points.replace(vector::X, scaling[0]*points.component(vector::X));
|
||||
points.replace(vector::Y, scaling[1]*points.component(vector::Y));
|
||||
points.replace(vector::Z, scaling[2]*points.component(vector::Z));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError
|
||||
<< "-scale with 1 or 3 components only" << nl
|
||||
<< "given: " << args["scale"] << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
surf1.movePoints(points);
|
||||
|
||||
Reference in New Issue
Block a user