mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-19 19:14:42 +00:00
gcc warnings, bugfixes and indentation
This commit is contained in:
parent
cf69669b71
commit
7b3abe760b
@ -497,7 +497,7 @@ void SdfGpuPlugin::vertexDataToTexture(MeshModel &m)
|
||||
delete [] vertexPosition;
|
||||
}
|
||||
|
||||
void SdfGpuPlugin::releaseGL(MeshModel &m)
|
||||
void SdfGpuPlugin::releaseGL(MeshModel &/*m*/)
|
||||
{
|
||||
glUseProgram(0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
@ -60,7 +60,7 @@ int saveMeshZip(string fileName, string internalName, string zipName) {
|
||||
}
|
||||
|
||||
mz_zip_writer_finalize_archive(&zip_archive);
|
||||
qDebug("Compressed %i",zip_archive.m_archive_size);
|
||||
qDebug("Compressed %llu",zip_archive.m_archive_size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -1495,9 +1495,14 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
||||
{
|
||||
if (r->m_type == 1)
|
||||
{
|
||||
mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i;
|
||||
r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
|
||||
for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8;
|
||||
mz_uint8 *p = r->m_tables[0].m_code_size;
|
||||
mz_uint i;
|
||||
r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32;
|
||||
TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
|
||||
for ( i = 0; i <= 143; ++i) *p++ = 8;
|
||||
for ( ; i <= 255; ++i) *p++ = 9;
|
||||
for ( ; i <= 279; ++i) *p++ = 7;
|
||||
for ( ; i <= 287; ++i) *p++ = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2281,12 +2286,17 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe
|
||||
if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break;
|
||||
TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE;
|
||||
}
|
||||
if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32;
|
||||
if (!dist) break;
|
||||
q = (const mz_uint16*)(d->m_dict + probe_pos);
|
||||
if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue;
|
||||
p = s; probe_len = 32;
|
||||
do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
|
||||
(TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
|
||||
if (!probe_len)
|
||||
{
|
||||
*pMatch_dist = dist; *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); break;
|
||||
*pMatch_dist = dist;
|
||||
*pMatch_len = MZ_MIN(max_match_len, (unsigned int)TDEFL_MAX_MATCH_LEN);
|
||||
break;
|
||||
}
|
||||
else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8*)p == *(const mz_uint8*)q)) > match_len)
|
||||
{
|
||||
@ -2414,7 +2424,7 @@ static mz_bool tdefl_compress_fast(tdefl_compressor *d)
|
||||
|
||||
total_lz_bytes += cur_match_len;
|
||||
lookahead_pos += cur_match_len;
|
||||
dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE);
|
||||
dict_size = MZ_MIN(dict_size + cur_match_len, (unsigned int)TDEFL_LZ_DICT_SIZE);
|
||||
cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK;
|
||||
MZ_ASSERT(lookahead_size >= cur_match_len);
|
||||
lookahead_size -= cur_match_len;
|
||||
@ -2442,7 +2452,7 @@ static mz_bool tdefl_compress_fast(tdefl_compressor *d)
|
||||
d->m_huff_count[0][lit]++;
|
||||
|
||||
lookahead_pos++;
|
||||
dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE);
|
||||
dict_size = MZ_MIN(dict_size + 1, (unsigned int)TDEFL_LZ_DICT_SIZE);
|
||||
cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK;
|
||||
lookahead_size--;
|
||||
|
||||
@ -2596,7 +2606,7 @@ static mz_bool tdefl_compress_normal(tdefl_compressor *d)
|
||||
d->m_lookahead_pos += len_to_move;
|
||||
MZ_ASSERT(d->m_lookahead_size >= len_to_move);
|
||||
d->m_lookahead_size -= len_to_move;
|
||||
d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, TDEFL_LZ_DICT_SIZE);
|
||||
d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, (unsigned int)TDEFL_LZ_DICT_SIZE);
|
||||
// Check if it's time to flush the current LZ codes to the internal output buffer.
|
||||
if ( (d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) ||
|
||||
( (d->m_total_lz_bytes > 31*1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) )
|
||||
@ -3614,7 +3624,7 @@ mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file
|
||||
else
|
||||
{
|
||||
// Temporarily allocate a read buffer.
|
||||
read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
read_buf_size = MZ_MIN(file_stat.m_comp_size, (size_t)MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
#ifdef _MSC_VER
|
||||
if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
|
||||
#else
|
||||
@ -3773,7 +3783,7 @@ mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_ind
|
||||
}
|
||||
else
|
||||
{
|
||||
read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
read_buf_size = MZ_MIN(file_stat.m_comp_size, (size_t)MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size)))
|
||||
return MZ_FALSE;
|
||||
read_buf_avail = 0;
|
||||
@ -4489,7 +4499,7 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
{
|
||||
while (uncomp_remaining)
|
||||
{
|
||||
mz_uint n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
|
||||
mz_uint n = (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
|
||||
if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n))
|
||||
{
|
||||
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
|
||||
@ -4528,7 +4538,7 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, (mz_uint32)MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
tdefl_status status;
|
||||
|
||||
if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
|
||||
@ -4632,12 +4642,12 @@ mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *
|
||||
n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
|
||||
comp_bytes_remaining = n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
|
||||
|
||||
if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining)))))
|
||||
if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN((size_t)MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining)))))
|
||||
return MZ_FALSE;
|
||||
|
||||
while (comp_bytes_remaining)
|
||||
{
|
||||
n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining);
|
||||
n = (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining);
|
||||
if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n)
|
||||
{
|
||||
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
|
||||
|
||||
@ -21,21 +21,20 @@ using namespace StructureSynth::Model::Rendering;
|
||||
using namespace SyntopiaCore::Exceptions;
|
||||
FilterSSynth::FilterSSynth(){
|
||||
typeList<< CR_SSYNTH;
|
||||
FilterIDType tt;
|
||||
this->renderTemplate= "";
|
||||
foreach(tt , types())
|
||||
for(FilterIDType tt : types())
|
||||
actionList << new QAction(filterName(tt), this);
|
||||
//num=0;
|
||||
//num=0;
|
||||
}
|
||||
//FilterSSynth::~FilterSSynth(){}
|
||||
QString FilterSSynth::filterName(FilterIDType filter) const
|
||||
{
|
||||
switch(filter)
|
||||
{
|
||||
case CR_SSYNTH:
|
||||
case CR_SSYNTH:
|
||||
return QString("Structure Synth Mesh Creation");
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
assert(0); return QString("error");
|
||||
break;
|
||||
}
|
||||
@ -45,32 +44,35 @@ QString FilterSSynth::filterInfo(FilterIDType filterId) const
|
||||
{
|
||||
switch(filterId)
|
||||
{
|
||||
case CR_SSYNTH:
|
||||
case CR_SSYNTH:
|
||||
return QString("Structure Synth mesh creation based on Eisen Script.\n For further instruction visit http://structuresynth.sourceforge.net/reference.php");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
assert(0); return QString("error");
|
||||
}
|
||||
}
|
||||
void FilterSSynth::initParameterSet(QAction* filter,MeshDocument &md, RichParameterSet &par)
|
||||
|
||||
void FilterSSynth::initParameterSet(QAction* /*filter*/,MeshDocument &/*md*/, RichParameterSet &par)
|
||||
{
|
||||
par.addParam(new RichString("grammar","set maxdepth 40 R1 R2 rule R1 { { x 1 rz 6 ry 6 s 0.99 } R1 { s 2 } sphere } rule R2 {{ x -1 rz 6 ry 6 s 0.99 } R2 { s 2 } sphere} ","Eisen Script grammar","Write a grammar according to Eisen Script specification and using the primitives box, sphere, mesh, dot and triangle "));
|
||||
par.addParam(new RichInt("seed",1,"seed for random construction","Seed needed to build the mesh"));
|
||||
par.addParam(new RichInt("sphereres",1,"set maximum resolution of sphere primitives, it must be included between 1 and 4","increasing the resolution of the spheres will improve the quality of the mesh "));
|
||||
return;
|
||||
par.addParam(new RichString("grammar","set maxdepth 40 R1 R2 rule R1 { { x 1 rz 6 ry 6 s 0.99 } R1 { s 2 } sphere } rule R2 {{ x -1 rz 6 ry 6 s 0.99 } R2 { s 2 } sphere} ","Eisen Script grammar","Write a grammar according to Eisen Script specification and using the primitives box, sphere, mesh, dot and triangle "));
|
||||
par.addParam(new RichInt("seed",1,"seed for random construction","Seed needed to build the mesh"));
|
||||
par.addParam(new RichInt("sphereres",1,"set maximum resolution of sphere primitives, it must be included between 1 and 4","increasing the resolution of the spheres will improve the quality of the mesh "));
|
||||
return;
|
||||
}
|
||||
void FilterSSynth::openX3D(const QString &fileName, MeshModel &m, int& mask, vcg::CallBackPos *cb, QWidget* parent)
|
||||
|
||||
void FilterSSynth::openX3D(const QString &fileName, MeshModel &m, int& mask, vcg::CallBackPos *cb, QWidget* /*parent*/)
|
||||
{
|
||||
vcg::tri::io::AdditionalInfoX3D* info = NULL;
|
||||
int result = vcg::tri::io::ImporterX3D<CMeshO>::LoadMask(fileName.toStdString().c_str(), info);
|
||||
m.Enable(info->mask);
|
||||
result = vcg::tri::io::ImporterX3D<CMeshO>::Open(m.cm, fileName.toStdString().c_str(), info, cb);
|
||||
/*vcg::tri::UpdateBounding<CMeshO>::Box(m.cm);
|
||||
vcg::tri::UpdateNormal<CMeshO>::PerVertexNormalizedPerFaceNormalized(m.cm);*/
|
||||
m.UpdateBoxAndNormals();
|
||||
mask=info->mask;
|
||||
delete(info);
|
||||
vcg::tri::io::AdditionalInfoX3D* info = NULL;
|
||||
/*int result = */vcg::tri::io::ImporterX3D<CMeshO>::LoadMask(fileName.toStdString().c_str(), info);
|
||||
m.Enable(info->mask);
|
||||
/*result = */vcg::tri::io::ImporterX3D<CMeshO>::Open(m.cm, fileName.toStdString().c_str(), info, cb);
|
||||
/*vcg::tri::UpdateBounding<CMeshO>::Box(m.cm);
|
||||
vcg::tri::UpdateNormal<CMeshO>::PerVertexNormalizedPerFaceNormalized(m.cm);*/
|
||||
m.UpdateBoxAndNormals();
|
||||
mask=info->mask;
|
||||
delete(info);
|
||||
}
|
||||
|
||||
bool FilterSSynth::applyFilter(QAction* filter, MeshDocument &md, RichParameterSet & par, vcg::CallBackPos *cb)
|
||||
{
|
||||
md.addNewMesh("",this->filterName(ID(filter)));
|
||||
@ -80,170 +82,180 @@ bool FilterSSynth::applyFilter(QAction* filter, MeshDocument &md, RichParameter
|
||||
int sphereres=par.findParameter("sphereres")->val->getInt();
|
||||
this->renderTemplate=GetTemplate(sphereres);
|
||||
if(this->renderTemplate!=QString::Null()){
|
||||
QString path=ssynth(grammar->val->getString(),-50,seed->val->getInt(),cb);
|
||||
if(QFile::exists(path)){
|
||||
QFile file(path);
|
||||
int mask;
|
||||
QString name(file.fileName());
|
||||
openX3D(name,*(md.mm()),mask,cb);
|
||||
file.remove();
|
||||
return true;
|
||||
QString path=ssynth(grammar->val->getString(),-50,seed->val->getInt(),cb);
|
||||
if(QFile::exists(path)){
|
||||
QFile file(path);
|
||||
int mask;
|
||||
QString name(file.fileName());
|
||||
openX3D(name,*(md.mm()),mask,cb);
|
||||
file.remove();
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
QString message=QString("An error occurred during the mesh generation:" ).append(path);
|
||||
QMessageBox::critical(parent,"Error",message);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
QMessageBox::critical(parent,"Error","Sphere resolution must be between 1 and 4"); return false;
|
||||
}
|
||||
}
|
||||
|
||||
int FilterSSynth::getRequirements(QAction *)
|
||||
{
|
||||
return MeshModel::MM_NONE;
|
||||
}
|
||||
QString FilterSSynth::ssynth(QString grammar,int maxdepth,int seed,CallBackPos *cb){
|
||||
|
||||
QString FilterSSynth::ssynth(QString grammar,int maxdepth,int seed,CallBackPos *cb){
|
||||
QString path("");
|
||||
if (cb != NULL) (*cb)(0, "Loading...");
|
||||
Template templ(this->renderTemplate);
|
||||
MyTrenderer renderer(templ);
|
||||
renderer.begin();
|
||||
Preprocessor pp;
|
||||
QString out = pp.Process(grammar);
|
||||
Tokenizer token(out);
|
||||
EisenParser parser(&token);
|
||||
try
|
||||
{
|
||||
RuleSet* rs=parser.parseRuleset();
|
||||
rs->resolveNames();
|
||||
rs->dumpInfo();
|
||||
if(maxdepth>0)rs->setRulesMaxDepth(maxdepth);
|
||||
RandomStreams::SetSeed(seed);
|
||||
Builder b(&renderer,rs,false);
|
||||
b.build();
|
||||
renderer.end();
|
||||
QString output=renderer.getOutput();
|
||||
(*cb)(0, "Temp");
|
||||
QFile file(QDir::tempPath() + "/output.x3d");
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)){(*cb)(0, "File has not been opened"); return QString("");}
|
||||
QTextStream outp(&file);
|
||||
outp << output;
|
||||
file.close();
|
||||
path=file.fileName();
|
||||
if (cb != NULL){ (*cb)(99, "Done");}
|
||||
}
|
||||
catch(Exception& ex){
|
||||
return ex.getMessage();
|
||||
}
|
||||
if (cb != NULL) (*cb)(0, "Loading...");
|
||||
Template templ(this->renderTemplate);
|
||||
MyTrenderer renderer(templ);
|
||||
renderer.begin();
|
||||
Preprocessor pp;
|
||||
QString out = pp.Process(grammar);
|
||||
Tokenizer token(out);
|
||||
EisenParser parser(&token);
|
||||
try
|
||||
{
|
||||
RuleSet* rs=parser.parseRuleset();
|
||||
rs->resolveNames();
|
||||
rs->dumpInfo();
|
||||
if(maxdepth>0)rs->setRulesMaxDepth(maxdepth);
|
||||
RandomStreams::SetSeed(seed);
|
||||
Builder b(&renderer,rs,false);
|
||||
b.build();
|
||||
renderer.end();
|
||||
QString output=renderer.getOutput();
|
||||
(*cb)(0, "Temp");
|
||||
QFile file(QDir::tempPath() + "/output.x3d");
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)){(*cb)(0, "File has not been opened"); return QString("");}
|
||||
QTextStream outp(&file);
|
||||
outp << output;
|
||||
file.close();
|
||||
path=file.fileName();
|
||||
if (cb != NULL){ (*cb)(99, "Done");}
|
||||
}
|
||||
catch(Exception& ex){
|
||||
return ex.getMessage();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
int FilterSSynth::postCondition(QAction* filter) const
|
||||
|
||||
int FilterSSynth::postCondition(QAction* /*filter*/) const
|
||||
{
|
||||
return MeshModel::MM_NONE;
|
||||
return MeshModel::MM_NONE;
|
||||
}
|
||||
MeshFilterInterface::FilterClass FilterSSynth::getClass(QAction *filter)
|
||||
|
||||
MeshFilterInterface::FilterClass FilterSSynth::getClass(QAction */*filter*/)
|
||||
{
|
||||
return MeshFilterInterface::MeshCreation;
|
||||
return MeshFilterInterface::MeshCreation;
|
||||
}
|
||||
|
||||
QList<MeshIOInterface::Format> FilterSSynth::importFormats() const
|
||||
{
|
||||
QList<MeshIOInterface::Format> formats;
|
||||
formats<< MeshIOInterface::Format("Eisen Script File", tr("ES"));
|
||||
return formats;
|
||||
}
|
||||
QList<MeshIOInterface::Format> FilterSSynth::exportFormats() const
|
||||
{
|
||||
QList<MeshIOInterface::Format> formats;
|
||||
return formats ;
|
||||
}
|
||||
bool FilterSSynth::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet & par, CallBackPos *cb, QWidget *parent)
|
||||
{
|
||||
this->seed=par.findParameter("seed")->val->getInt();
|
||||
int maxrec=par.findParameter("maxrec")->val->getInt();
|
||||
int sphereres=par.findParameter("sphereres")->val->getInt();
|
||||
int maxobj=par.findParameter("maxobj")->val->getInt();
|
||||
this->renderTemplate=GetTemplate(sphereres);
|
||||
if(this->renderTemplate!=QString::Null()){
|
||||
QList<MeshIOInterface::Format> formats;
|
||||
formats<< MeshIOInterface::Format("Eisen Script File", tr("ES"));
|
||||
return formats;
|
||||
}
|
||||
|
||||
QList<MeshIOInterface::Format> FilterSSynth::exportFormats() const
|
||||
{
|
||||
QList<MeshIOInterface::Format> formats;
|
||||
return formats ;
|
||||
}
|
||||
|
||||
bool FilterSSynth::open(const QString &/*formatName*/, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet & par, CallBackPos *cb, QWidget *parent)
|
||||
{
|
||||
this->seed=par.findParameter("seed")->val->getInt();
|
||||
int maxrec=par.findParameter("maxrec")->val->getInt();
|
||||
int sphereres=par.findParameter("sphereres")->val->getInt();
|
||||
int maxobj=par.findParameter("maxobj")->val->getInt();
|
||||
this->renderTemplate=GetTemplate(sphereres);
|
||||
if(this->renderTemplate!=QString::Null()){
|
||||
QFile grammar(fileName);
|
||||
grammar.open(QFile::ReadOnly|QFile::Text);
|
||||
grammar.open(QFile::ReadOnly|QFile::Text);
|
||||
QString gcontent(grammar.readAll());
|
||||
grammar.close();
|
||||
if(maxrec>0)ParseGram(&gcontent,maxrec,tr("set maxdepth"));
|
||||
if(maxobj>0)ParseGram(&gcontent,maxobj,tr("set maxobjects"));
|
||||
if(maxrec>0)ParseGram(&gcontent,maxrec,tr("set maxdepth"));
|
||||
if(maxobj>0)ParseGram(&gcontent,maxobj,tr("set maxobjects"));
|
||||
QString x3dfile(FilterSSynth::ssynth(gcontent,maxrec,this->seed,cb));
|
||||
if(QFile::exists(x3dfile)){
|
||||
openX3D(x3dfile,m,mask,cb);
|
||||
QFile x3df(x3dfile);
|
||||
x3df.remove();
|
||||
return true;
|
||||
openX3D(x3dfile,m,mask,cb);
|
||||
QFile x3df(x3dfile);
|
||||
x3df.remove();
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
QMessageBox::critical(parent,tr("Error"),tr("An error occurred during the mesh generation: ").append(x3dfile));
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{ QMessageBox::critical(parent,"Error","Sphere resolution must be between 1 and 4"); return false;}
|
||||
}
|
||||
bool FilterSSynth::save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask, const RichParameterSet &, vcg::CallBackPos *cb, QWidget *parent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void FilterSSynth::GetExportMaskCapability(QString &format, int &capability, int &defaultBits) const{}
|
||||
void FilterSSynth::initPreOpenParameter(const QString &formatName, const QString &filename, RichParameterSet &parlst){
|
||||
parlst.addParam(new RichInt(tr("seed"),1,tr("Seed for random mesh generation"),tr("write a seed for the random generation of the mesh")));
|
||||
parlst.addParam(new RichInt("maxrec",0,"set the maximum recursion","the mesh is built recursively according to the productions of the grammar, so a limit is needed. If set to 0 meshlab will generate the mesh according to the maximum recursion set in the file"));
|
||||
parlst.addParam(new RichInt("sphereres",1,"set maximum resolution of sphere primitives, it must be included between 1 and 4","increasing the resolution of the spheres will improve the quality of the mesh "));
|
||||
parlst.addParam(new RichInt("maxobj",0,"set the maximum number of object to be rendered","you can set a limit to the maximum number of primitives rendered. If set to 0 meshlab will generate the mesh according to the input file"));
|
||||
}
|
||||
QString FilterSSynth::GetTemplate(int sphereres){
|
||||
QString filen;
|
||||
switch(sphereres){
|
||||
case 1:
|
||||
filen=":/x3d.rendertemplate";
|
||||
break;
|
||||
case 2:
|
||||
filen=":/x3d2.rendertemplate";
|
||||
break;
|
||||
case 3:
|
||||
filen=":/x3d3.rendertemplate";
|
||||
break;
|
||||
case 4:
|
||||
filen=":/x3d4.rendertemplate";
|
||||
break;
|
||||
default:
|
||||
return QString::Null();
|
||||
break;
|
||||
}
|
||||
QFile tr(filen);
|
||||
tr.open(QFile::ReadOnly|QFile::Text);
|
||||
QString templateR(tr.readAll());
|
||||
return templateR;
|
||||
}
|
||||
void FilterSSynth::ParseGram(QString* grammar, int max,QString pattern){
|
||||
int idx=grammar->indexOf(pattern);
|
||||
if(idx>-1){
|
||||
int end=pattern.length()+idx;
|
||||
while(!grammar->operator [](end).isNumber())
|
||||
end++;
|
||||
QString grec;
|
||||
while(grammar->operator [](end).isNumber()){
|
||||
grec.append(grammar->operator [](end));
|
||||
end++;
|
||||
}
|
||||
QString tosub=QString(pattern).append(" ").append(QString::number(max)).append(" ");
|
||||
QString maxrestr=grammar->mid(idx,end-idx);
|
||||
else{ QMessageBox::critical(parent,"Error","Sphere resolution must be between 1 and 4"); return false;}
|
||||
}
|
||||
|
||||
bool FilterSSynth::save(const QString &/*formatName*/, const QString &/*fileName*/, MeshModel &/*m*/, const int /*mask*/, const RichParameterSet &, vcg::CallBackPos */*cb*/, QWidget */*parent*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void FilterSSynth::GetExportMaskCapability(QString &/*format*/, int &/*capability*/, int &/*defaultBits*/) const {}
|
||||
|
||||
void FilterSSynth::initPreOpenParameter(const QString &/*formatName*/, const QString &/*filename*/, RichParameterSet &parlst){
|
||||
parlst.addParam(new RichInt(tr("seed"),1,tr("Seed for random mesh generation"),tr("write a seed for the random generation of the mesh")));
|
||||
parlst.addParam(new RichInt("maxrec",0,"set the maximum recursion","the mesh is built recursively according to the productions of the grammar, so a limit is needed. If set to 0 meshlab will generate the mesh according to the maximum recursion set in the file"));
|
||||
parlst.addParam(new RichInt("sphereres",1,"set maximum resolution of sphere primitives, it must be included between 1 and 4","increasing the resolution of the spheres will improve the quality of the mesh "));
|
||||
parlst.addParam(new RichInt("maxobj",0,"set the maximum number of object to be rendered","you can set a limit to the maximum number of primitives rendered. If set to 0 meshlab will generate the mesh according to the input file"));
|
||||
}
|
||||
|
||||
QString FilterSSynth::GetTemplate(int sphereres){
|
||||
QString filen;
|
||||
switch(sphereres){
|
||||
case 1:
|
||||
filen=":/x3d.rendertemplate";
|
||||
break;
|
||||
case 2:
|
||||
filen=":/x3d2.rendertemplate";
|
||||
break;
|
||||
case 3:
|
||||
filen=":/x3d3.rendertemplate";
|
||||
break;
|
||||
case 4:
|
||||
filen=":/x3d4.rendertemplate";
|
||||
break;
|
||||
default:
|
||||
return QString::Null();
|
||||
break;
|
||||
}
|
||||
QFile tr(filen);
|
||||
tr.open(QFile::ReadOnly|QFile::Text);
|
||||
QString templateR(tr.readAll());
|
||||
return templateR;
|
||||
}
|
||||
|
||||
void FilterSSynth::ParseGram(QString* grammar, int max,QString pattern){
|
||||
int idx=grammar->indexOf(pattern);
|
||||
if(idx>-1){
|
||||
int end=pattern.length()+idx;
|
||||
while(!grammar->operator [](end).isNumber())
|
||||
end++;
|
||||
QString grec;
|
||||
while(grammar->operator [](end).isNumber()){
|
||||
grec.append(grammar->operator [](end));
|
||||
end++;
|
||||
}
|
||||
QString tosub=QString(pattern).append(" ").append(QString::number(max)).append(" ");
|
||||
QString maxrestr=grammar->mid(idx,end-idx);
|
||||
/* if(pattern=="set maxobjects")grammar->replace(maxrestr,tosub);
|
||||
else if(grec.toInt()<max)grammar->replace(maxrestr,tosub);*/
|
||||
grammar->replace(maxrestr,tosub);
|
||||
}
|
||||
|
||||
else if(pattern=="set maxobjects"){
|
||||
QString tosub=QString(pattern).append(" ").append(QString::number(max)).append(" \n");
|
||||
grammar->insert(0,tosub);
|
||||
}
|
||||
}
|
||||
MESHLAB_PLUGIN_NAME_EXPORTER(FilterSSynth)
|
||||
|
||||
grammar->replace(maxrestr,tosub);
|
||||
}
|
||||
|
||||
else if(pattern=="set maxobjects"){
|
||||
QString tosub=QString(pattern).append(" ").append(QString::number(max)).append(" \n");
|
||||
grammar->insert(0,tosub);
|
||||
}
|
||||
}
|
||||
|
||||
MESHLAB_PLUGIN_NAME_EXPORTER(FilterSSynth)
|
||||
|
||||
@ -43,7 +43,7 @@ public:
|
||||
virtual QString filterName(FilterIDType filter) const;
|
||||
virtual QString filterInfo(FilterIDType filter) const;
|
||||
virtual int getRequirements(QAction *);
|
||||
virtual void initParameterSet(QAction* filter,MeshModel &,RichParameterSet &){};
|
||||
virtual void initParameterSet(QAction* /*filter*/,MeshModel &,RichParameterSet &){};
|
||||
virtual void initParameterSet(QAction *,MeshDocument &/*m*/, RichParameterSet & /*parent*/);
|
||||
virtual bool applyFilter(QAction* filter, MeshDocument &md, RichParameterSet & par, vcg::CallBackPos *cb);
|
||||
virtual FilterClass getClass(QAction* filter);
|
||||
|
||||
@ -1,128 +1,129 @@
|
||||
#include "mytrenderer.h"
|
||||
|
||||
using namespace StructureSynth::Model::Rendering;
|
||||
using namespace SyntopiaCore::GLEngine;
|
||||
using namespace SyntopiaCore::Math;
|
||||
using namespace StructureSynth::Model;
|
||||
void MyTrenderer::drawBox(SyntopiaCore::Math::Vector3f base,
|
||||
SyntopiaCore::Math::Vector3f dir1 ,
|
||||
SyntopiaCore::Math::Vector3f dir2,
|
||||
SyntopiaCore::Math::Vector3f dir3,
|
||||
PrimitiveClass* classID)
|
||||
SyntopiaCore::Math::Vector3f dir1 ,
|
||||
SyntopiaCore::Math::Vector3f dir2,
|
||||
SyntopiaCore::Math::Vector3f dir3,
|
||||
PrimitiveClass* /*classID*/)
|
||||
{
|
||||
TemplatePrimitive t(workingTempl.get("box"));
|
||||
if(t.contains("{x3dvectors}")){
|
||||
QString mat = QString("translation=\"%1 %2 %3\"")
|
||||
.arg(base.x()).arg(base.y()).arg(base.z());
|
||||
QString coord=QString("%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18 %19 %20 %21 %22 %23 %24")
|
||||
.arg(0).arg(0).arg(0)
|
||||
.arg(dir3.x()).arg(dir3.y()).arg(dir3.z())
|
||||
.arg(dir2.x()).arg(dir2.y()).arg(dir2.z())
|
||||
.arg((dir2+dir3).x()).arg((dir2+dir3).y()).arg((dir2+dir3).z())
|
||||
.arg(dir1.x()).arg(dir1.y()).arg(dir1.z())
|
||||
.arg((dir1+dir3).x()).arg((dir1+dir3).y()).arg((dir1+dir3).z())
|
||||
.arg((dir1+dir2).x()).arg((dir1+dir2).y()).arg((dir1+dir2).z())
|
||||
.arg((dir1+dir2+dir3).x()).arg((dir1+dir2+dir3).y()).arg((dir1+dir2+dir3).z());
|
||||
t.substitute("{coords}",coord);
|
||||
t.substitute("{x3dvectors}",mat);
|
||||
}
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
TemplatePrimitive t(workingTempl.get("box"));
|
||||
if(t.contains("{x3dvectors}")){
|
||||
QString mat = QString("translation=\"%1 %2 %3\"")
|
||||
.arg(base.x()).arg(base.y()).arg(base.z());
|
||||
QString coord=QString("%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18 %19 %20 %21 %22 %23 %24")
|
||||
.arg(0).arg(0).arg(0)
|
||||
.arg(dir3.x()).arg(dir3.y()).arg(dir3.z())
|
||||
.arg(dir2.x()).arg(dir2.y()).arg(dir2.z())
|
||||
.arg((dir2+dir3).x()).arg((dir2+dir3).y()).arg((dir2+dir3).z())
|
||||
.arg(dir1.x()).arg(dir1.y()).arg(dir1.z())
|
||||
.arg((dir1+dir3).x()).arg((dir1+dir3).y()).arg((dir1+dir3).z())
|
||||
.arg((dir1+dir2).x()).arg((dir1+dir2).y()).arg((dir1+dir2).z())
|
||||
.arg((dir1+dir2+dir3).x()).arg((dir1+dir2+dir3).y()).arg((dir1+dir2+dir3).z());
|
||||
t.substitute("{coords}",coord);
|
||||
t.substitute("{x3dvectors}",mat);
|
||||
}
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::drawSphere(SyntopiaCore::Math::Vector3f center, float radius, SyntopiaCore::GLEngine::PrimitiveClass *classID){
|
||||
TemplatePrimitive t(workingTempl.get("sphere"));
|
||||
t.substitute("{cx}", QString::number(center.x()));
|
||||
t.substitute("{cy}", QString::number(center.y()));
|
||||
t.substitute("{cz}", QString::number(center.z()));
|
||||
if(t.contains("{x3dsphscale}")){
|
||||
float diff=radius;
|
||||
QString scale=QString("%1 %2 %3")
|
||||
.arg(diff).arg(diff).arg(diff);
|
||||
t.substitute("{x3dsphscale}",scale);
|
||||
|
||||
}
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
t.substitute("{rad}", QString::number(radius));
|
||||
output.append(t.getText());
|
||||
void MyTrenderer::drawSphere(SyntopiaCore::Math::Vector3f center, float radius, SyntopiaCore::GLEngine::PrimitiveClass * /*classID*/){
|
||||
TemplatePrimitive t(workingTempl.get("sphere"));
|
||||
t.substitute("{cx}", QString::number(center.x()));
|
||||
t.substitute("{cy}", QString::number(center.y()));
|
||||
t.substitute("{cz}", QString::number(center.z()));
|
||||
if(t.contains("{x3dsphscale}")){
|
||||
float diff=radius;
|
||||
QString scale=QString("%1 %2 %3")
|
||||
.arg(diff).arg(diff).arg(diff);
|
||||
t.substitute("{x3dsphscale}",scale);
|
||||
|
||||
}
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
t.substitute("{rad}", QString::number(radius));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::drawMesh(SyntopiaCore::Math::Vector3f startBase,
|
||||
SyntopiaCore::Math::Vector3f startDir1,
|
||||
SyntopiaCore::Math::Vector3f startDir2,
|
||||
SyntopiaCore::Math::Vector3f endBase,
|
||||
SyntopiaCore::Math::Vector3f endDir1,
|
||||
SyntopiaCore::Math::Vector3f endDir2,
|
||||
SyntopiaCore::GLEngine::PrimitiveClass* classID)
|
||||
SyntopiaCore::Math::Vector3f startDir1,
|
||||
SyntopiaCore::Math::Vector3f startDir2,
|
||||
SyntopiaCore::Math::Vector3f endBase,
|
||||
SyntopiaCore::Math::Vector3f endDir1,
|
||||
SyntopiaCore::Math::Vector3f endDir2,
|
||||
SyntopiaCore::GLEngine::PrimitiveClass* /*classID*/)
|
||||
{
|
||||
TemplatePrimitive t(workingTempl.get("mesh"));
|
||||
if(t.contains("{x3dtranslate}")){
|
||||
Vector3f end=endBase - startBase;
|
||||
Vector3f O(0,0,0);
|
||||
QString tslate=QString("%1 %2 %3")
|
||||
.arg(startBase.x()).arg(startBase.y()).arg(startBase.z());
|
||||
Vector3f coords[10]={O,startDir1,startDir2,endDir1,endDir2,end,(end+endDir1),(end+endDir2),(startDir1+startDir2),(end+endDir1+endDir2)};
|
||||
QString coord("");
|
||||
for(int i=0;i<10;i++)
|
||||
coord.append(QString::number(coords[i].x())).append(" ").append(QString::number(coords[i].y())).append(" ").append(QString::number(coords[i].z())).append(" ");
|
||||
t.substitute("{x3dtranslate}",tslate);
|
||||
t.substitute("{x3dcoord}",coord);
|
||||
}
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
TemplatePrimitive t(workingTempl.get("mesh"));
|
||||
if(t.contains("{x3dtranslate}")){
|
||||
Vector3f end=endBase - startBase;
|
||||
Vector3f O(0,0,0);
|
||||
QString tslate=QString("%1 %2 %3")
|
||||
.arg(startBase.x()).arg(startBase.y()).arg(startBase.z());
|
||||
Vector3f coords[10]={O,startDir1,startDir2,endDir1,endDir2,end,(end+endDir1),(end+endDir2),(startDir1+startDir2),(end+endDir1+endDir2)};
|
||||
QString coord("");
|
||||
for(int i=0;i<10;i++)
|
||||
coord.append(QString::number(coords[i].x())).append(" ").append(QString::number(coords[i].y())).append(" ").append(QString::number(coords[i].z())).append(" ");
|
||||
t.substitute("{x3dtranslate}",tslate);
|
||||
t.substitute("{x3dcoord}",coord);
|
||||
}
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
}
|
||||
QString MyTrenderer::getOutput() {
|
||||
QString out = output.join("");
|
||||
QString MyTrenderer::getOutput() {
|
||||
QString out = output.join("");
|
||||
|
||||
// Normalize output (seems the '\n' converts to CR+LF on windows while saving
|
||||
// whereas '\r\n' converts to CR+CR+LF? so we remove the \r's).
|
||||
out = out.replace("\r","");
|
||||
return out;
|
||||
}
|
||||
void MyTrenderer::begin(){
|
||||
TemplatePrimitive t(workingTempl.get("begin"));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::end(){
|
||||
TemplatePrimitive t(workingTempl.get("end"));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::drawDot(SyntopiaCore::Math::Vector3f v,PrimitiveClass* classID) {
|
||||
TemplatePrimitive t(workingTempl.get("dot"));
|
||||
t.substitute("{x}", QString::number(v.x()));
|
||||
t.substitute("{y}", QString::number(v.y()));
|
||||
t.substitute("{z}", QString::number(v.z()));
|
||||
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::drawTriangle(SyntopiaCore::Math::Vector3f p1,
|
||||
SyntopiaCore::Math::Vector3f p2,
|
||||
SyntopiaCore::Math::Vector3f p3,
|
||||
PrimitiveClass* classID) {
|
||||
TemplatePrimitive t(workingTempl.get("triangle"));
|
||||
t.substitute("{p1x}", QString::number(p1.x()));
|
||||
t.substitute("{p1y}", QString::number(p1.y()));
|
||||
t.substitute("{p1z}", QString::number(p1.z()));
|
||||
t.substitute("{p2x}", QString::number(p2.x()));
|
||||
t.substitute("{p2y}", QString::number(p2.y()));
|
||||
t.substitute("{p2z}", QString::number(p2.z()));
|
||||
t.substitute("{p3x}", QString::number(p3.x()));
|
||||
t.substitute("{p3y}", QString::number(p3.y()));
|
||||
t.substitute("{p3z}", QString::number(p3.z()));
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
// Normalize output (seems the '\n' converts to CR+LF on windows while saving
|
||||
// whereas '\r\n' converts to CR+CR+LF? so we remove the \r's).
|
||||
out = out.replace("\r","");
|
||||
return out;
|
||||
}
|
||||
void MyTrenderer::begin(){
|
||||
TemplatePrimitive t(workingTempl.get("begin"));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::end(){
|
||||
TemplatePrimitive t(workingTempl.get("end"));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::drawDot(SyntopiaCore::Math::Vector3f v,PrimitiveClass* /*classID*/) {
|
||||
TemplatePrimitive t(workingTempl.get("dot"));
|
||||
t.substitute("{x}", QString::number(v.x()));
|
||||
t.substitute("{y}", QString::number(v.y()));
|
||||
t.substitute("{z}", QString::number(v.z()));
|
||||
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
}
|
||||
void MyTrenderer::drawTriangle(SyntopiaCore::Math::Vector3f p1,
|
||||
SyntopiaCore::Math::Vector3f p2,
|
||||
SyntopiaCore::Math::Vector3f p3,
|
||||
PrimitiveClass* /*classID*/) {
|
||||
TemplatePrimitive t(workingTempl.get("triangle"));
|
||||
t.substitute("{p1x}", QString::number(p1.x()));
|
||||
t.substitute("{p1y}", QString::number(p1.y()));
|
||||
t.substitute("{p1z}", QString::number(p1.z()));
|
||||
t.substitute("{p2x}", QString::number(p2.x()));
|
||||
t.substitute("{p2y}", QString::number(p2.y()));
|
||||
t.substitute("{p2z}", QString::number(p2.z()));
|
||||
t.substitute("{p3x}", QString::number(p3.x()));
|
||||
t.substitute("{p3y}", QString::number(p3.y()));
|
||||
t.substitute("{p3z}", QString::number(p3.z()));
|
||||
t.substitute("{r}", QString::number(rgb.x()));
|
||||
t.substitute("{g}", QString::number(rgb.y()));
|
||||
t.substitute("{b}", QString::number(rgb.z()));
|
||||
t.substitute("{alpha}", QString::number(alpha));
|
||||
output.append(t.getText());
|
||||
}
|
||||
|
||||
@ -434,12 +434,12 @@ bool FilterTexturePlugin::applyFilter(QAction *filter, MeshDocument &md, RichPar
|
||||
int sideDim = par.getInt("sidedim");
|
||||
int textDim = par.getInt("textdim");
|
||||
int pxBorder = par.getInt("border");
|
||||
bool adv;
|
||||
bool adv = false;
|
||||
switch(par.getEnum("method")) {
|
||||
case 0 : adv = false; break; // Basic
|
||||
case 1 : adv = true; break; // Advanced
|
||||
default : assert(0);
|
||||
};
|
||||
case 0 : adv = false; break; // Basic
|
||||
case 1 : adv = true; break; // Advanced
|
||||
default : assert(0);
|
||||
};
|
||||
|
||||
// Pre checks
|
||||
CheckError(textDim <= 0, "Texture Dimension has an incorrect value");
|
||||
@ -1056,7 +1056,7 @@ bool FilterTexturePlugin::applyFilter(QAction *filter, MeshDocument &md, RichPar
|
||||
srcImgs.resize(srcMesh->cm.textures.size());
|
||||
QString path;
|
||||
|
||||
for (int textInd = 0; textInd < srcMesh->cm.textures.size(); textInd++)
|
||||
for (size_t textInd = 0; textInd < srcMesh->cm.textures.size(); textInd++)
|
||||
{
|
||||
path = m.fullName();
|
||||
path = path.left(std::max<int>(path.lastIndexOf('\\'), path.lastIndexOf('/')) + 1).append(srcMesh->cm.textures[textInd].c_str());
|
||||
|
||||
@ -76,12 +76,12 @@ public:
|
||||
|
||||
// Convert point to barycentric coords
|
||||
CMeshO::CoordType interp;
|
||||
bool ret = InterpolationParameters(*nearestF, nearestF->cN(), closestPt, interp);
|
||||
/*bool ret = */InterpolationParameters(*nearestF, nearestF->cN(), closestPt, interp);
|
||||
assert(ret);
|
||||
interp[2]=1.0-interp[1]-interp[0];
|
||||
|
||||
int tIndex = nearestF->cWT(0).N();
|
||||
if ((tIndex >= 0) && (tIndex < srcImgs.size()))
|
||||
if ((tIndex >= 0) && ((size_t)tIndex < srcImgs.size()))
|
||||
{
|
||||
int w = srcImgs[tIndex].width(), h = srcImgs[tIndex].height();
|
||||
int x, y;
|
||||
@ -254,7 +254,7 @@ public:
|
||||
if (p[0] <.0) {alpha = 254+p[0]*128; bary[0] = 0.;} else
|
||||
if (p[1] <.0) {alpha = 254+p[1]*128; bary[1] = 0.;} else
|
||||
if (p[2] <.0) {alpha = 254+p[2]*128; bary[2] = 0.;}*/
|
||||
int rr,gg,bb;
|
||||
int rr=0,gg=0,bb=0;
|
||||
CMeshO::CoordType bary = p;
|
||||
int alpha = 255;
|
||||
if (edgeDist != 0.0)
|
||||
@ -346,7 +346,7 @@ public:
|
||||
else
|
||||
{
|
||||
// Calculate and set color
|
||||
CMeshO::VertexType::ColorType c;
|
||||
CMeshO::VertexType::ColorType c(0);
|
||||
switch(vertexMode)
|
||||
{
|
||||
case 0 : // Color
|
||||
|
||||
@ -198,10 +198,10 @@ bool FilterVoronoiPlugin::applyFilter( const QString& filterName,MeshDocument& m
|
||||
CMeshO::ScalarType sampleSurfRadius = env.evalFloat("sampleSurfRadius");
|
||||
CMeshO::ScalarType poissonRadius = env.evalFloat("poissonRadius");
|
||||
int sampleVolNum = env.evalInt("sampleVolNum");
|
||||
int poissonFlag = env.evalBool("poissonFiltering");
|
||||
/*int poissonFlag = */env.evalBool("poissonFiltering");
|
||||
|
||||
MeshModel *mcVm= md.addOrGetMesh("Montecarlo Volume","Montecarlo Volume",false);
|
||||
MeshModel *pVm= md.addOrGetMesh("Poisson Sampling","Poisson Sampling",false);
|
||||
/*MeshModel *pVm= */md.addOrGetMesh("Poisson Sampling","Poisson Sampling",false);
|
||||
MeshModel *pSm= md.addOrGetMesh("Surface Sampling","Surface Sampling",false);
|
||||
mcVm->updateDataMask(MeshModel::MM_VERTCOLOR | MeshModel::MM_VERTQUALITY);
|
||||
pSm->updateDataMask(MeshModel::MM_VERTCOLOR | MeshModel::MM_VERTQUALITY);
|
||||
@ -223,7 +223,7 @@ bool FilterVoronoiPlugin::applyFilter( const QString& filterName,MeshDocument& m
|
||||
m->updateDataMask(MeshModel::MM_FACEMARK);
|
||||
MeshModel *pm= md.addOrGetMesh("Poisson-disk Samples","Poisson-disk Samples",false);
|
||||
MeshModel *mcVm= md.addOrGetMesh("Montecarlo Volume","Montecarlo Volume",false);
|
||||
MeshModel *vsm= md.addOrGetMesh("Voronoi Seeds","Voronoi Seeds",false);
|
||||
/*MeshModel *vsm= */md.addOrGetMesh("Voronoi Seeds","Voronoi Seeds",false);
|
||||
MeshModel *sm= md.addOrGetMesh("Scaffolding","Scaffolding",false);
|
||||
|
||||
pm->updateDataMask(m);
|
||||
@ -259,8 +259,8 @@ bool FilterVoronoiPlugin::applyFilter( const QString& filterName,MeshDocument& m
|
||||
cb(90, "Final Smoothing...");
|
||||
tri::Smooth<CMeshO>::VertexCoordLaplacian(sm->cm, smoothStep);
|
||||
sm->UpdateBoxAndNormals();
|
||||
tri::Append<CMeshO,CMeshO>::MeshCopy(mcVm->cm,vvs.montecarloVolumeMesh);
|
||||
tri::Append<CMeshO,CMeshO>::MeshCopy(pm->cm,vvs.psd.poissonSurfaceMesh);
|
||||
tri::Append<CMeshO,CMeshO>::MeshCopy(mcVm->cm,vvs.montecarloVolumeMesh);
|
||||
tri::Append<CMeshO,CMeshO>::MeshCopy(pm->cm,vvs.psd.poissonSurfaceMesh);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user