add scale factor in GeometryDict
This commit is contained in:
parent
8da8afbe63
commit
888e5eb4cb
|
@ -52,7 +52,8 @@ bool pFlow::stlFile::readSolid
|
||||||
(
|
(
|
||||||
iIstream& is,
|
iIstream& is,
|
||||||
realx3x3Vector & vertecies,
|
realx3x3Vector & vertecies,
|
||||||
word & name
|
word & name,
|
||||||
|
real scaleFactor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ bool pFlow::stlFile::readSolid
|
||||||
// read facet
|
// read facet
|
||||||
is.putBack(tok);
|
is.putBack(tok);
|
||||||
realx3x3 tri;
|
realx3x3 tri;
|
||||||
if( !readFacet(is, tri) ) return false;
|
if( !readFacet(is, tri, scaleFactor) ) return false;
|
||||||
|
|
||||||
vertecies.push_back(tri);
|
vertecies.push_back(tri);
|
||||||
|
|
||||||
|
@ -126,7 +127,8 @@ bool pFlow::stlFile::readSolid
|
||||||
bool pFlow::stlFile::readFacet
|
bool pFlow::stlFile::readFacet
|
||||||
(
|
(
|
||||||
iIstream& is,
|
iIstream& is,
|
||||||
realx3x3& tri
|
realx3x3& tri,
|
||||||
|
real scaleFactor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
|
@ -162,9 +164,9 @@ bool pFlow::stlFile::readFacet
|
||||||
if(!checkNumberToken(is, tok, v.y()))return false;
|
if(!checkNumberToken(is, tok, v.y()))return false;
|
||||||
is>>tok;
|
is>>tok;
|
||||||
if(!checkNumberToken(is, tok, v.z()))return false;
|
if(!checkNumberToken(is, tok, v.z()))return false;
|
||||||
if( i==0 ) tri.x() = v;
|
if( i==0 ) tri.x() = v * scaleFactor;
|
||||||
if( i==1 ) tri.y() = v;
|
if( i==1 ) tri.y() = v * scaleFactor;
|
||||||
if( i==2) tri.z() = v;
|
if( i==2) tri.z() = v * scaleFactor;
|
||||||
}
|
}
|
||||||
is>> tok;
|
is>> tok;
|
||||||
if(!checkWordToken(is, tok, "endloop")) return false;
|
if(!checkWordToken(is, tok, "endloop")) return false;
|
||||||
|
@ -289,7 +291,7 @@ void pFlow::stlFile::addSolid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::stlFile::read()
|
bool pFlow::stlFile::read(real scaleFactor)
|
||||||
{
|
{
|
||||||
solids_.clear();
|
solids_.clear();
|
||||||
solidNames_.clear();
|
solidNames_.clear();
|
||||||
|
@ -303,7 +305,7 @@ bool pFlow::stlFile::read()
|
||||||
|
|
||||||
realx3x3Vector vertecies;
|
realx3x3Vector vertecies;
|
||||||
word name;
|
word name;
|
||||||
if(!readSolid(is, vertecies, name))
|
if(!readSolid(is, vertecies, name, scaleFactor))
|
||||||
{
|
{
|
||||||
ioErrorInFile(is.name(), is.lineNumber());
|
ioErrorInFile(is.name(), is.lineNumber());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -52,9 +52,9 @@ protected:
|
||||||
|
|
||||||
// - protected members
|
// - protected members
|
||||||
|
|
||||||
bool readSolid(iIstream& is, realx3x3Vector & vertecies, word & name);
|
bool readSolid(iIstream& is, realx3x3Vector & vertecies, word & name, real scaleFactor);
|
||||||
|
|
||||||
bool readFacet(iIstream& is, realx3x3& tri);
|
bool readFacet(iIstream& is, realx3x3& tri, real scaleFactor);
|
||||||
|
|
||||||
bool writeSolid(iOstream& os, const realx3x3Vector& vertecies, const word& name)const;
|
bool writeSolid(iOstream& os, const realx3x3Vector& vertecies, const word& name)const;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
void addSolid(const word& name, realx3x3Vector&& vertecies);
|
void addSolid(const word& name, realx3x3Vector&& vertecies);
|
||||||
|
|
||||||
// - clear current content and read from file
|
// - clear current content and read from file
|
||||||
bool read();
|
bool read(real scaleFactor);
|
||||||
|
|
||||||
// - write the current contnet to file
|
// - write the current contnet to file
|
||||||
bool write()const;
|
bool write()const;
|
||||||
|
|
|
@ -31,11 +31,13 @@ bool pFlow::stlWall::readSTLWall
|
||||||
{
|
{
|
||||||
auto fileName = dict.getVal<word>("file");
|
auto fileName = dict.getVal<word>("file");
|
||||||
|
|
||||||
|
real scale = dict.getValOrSet("scale", static_cast<real>(1.0));
|
||||||
|
|
||||||
|
|
||||||
fileSystem file("./stl",fileName);
|
fileSystem file("./stl",fileName);
|
||||||
|
|
||||||
stlFile stl(file);
|
stlFile stl(file);
|
||||||
if(!stl.read())
|
if(!stl.read(scale))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction <<
|
fatalErrorInFunction <<
|
||||||
" error in reading stl file "<< file <<endl;
|
" error in reading stl file "<< file <<endl;
|
||||||
|
|
Loading…
Reference in New Issue