mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-15 00:54:38 +00:00
meshList and rasterList to std::list
This commit is contained in:
parent
0c7cbe8d78
commit
d5f92fe254
@ -16,9 +16,7 @@ MeshDocumentStateData::~MeshDocumentStateData()
|
||||
void MeshDocumentStateData::create(MeshDocument& md)
|
||||
{
|
||||
QWriteLocker locker(&_lock);
|
||||
for (int ii = 0; ii < md.meshList.size(); ++ii)
|
||||
{
|
||||
MeshModel* mm = md.meshList[ii];
|
||||
for (MeshModel* mm :md.meshList) {
|
||||
if (mm != NULL)
|
||||
insert(mm->id(), MeshModelStateData(mm->dataMask(), mm->cm.VN(), mm->cm.FN(), mm->cm.EN()));
|
||||
}
|
||||
|
||||
@ -24,10 +24,10 @@
|
||||
#include "mesh_document.h"
|
||||
|
||||
template <class LayerElement>
|
||||
QString NameDisambiguator(QList<LayerElement*> &elemList, QString meshLabel )
|
||||
QString NameDisambiguator(std::list<LayerElement*> &elemList, QString meshLabel )
|
||||
{
|
||||
QString newName=std::move(meshLabel);
|
||||
typename QList<LayerElement*>::iterator mmi;
|
||||
typename std::list<LayerElement*>::iterator mmi;
|
||||
|
||||
for(mmi=elemList.begin(); mmi!=elemList.end(); ++mmi)
|
||||
{
|
||||
@ -193,26 +193,31 @@ MeshModel* MeshDocument::nextVisibleMesh(MeshModel* _m)
|
||||
MeshModel* MeshDocument::nextMesh(MeshModel* _m)
|
||||
{
|
||||
if(_m==0 && meshList.size()>0)
|
||||
return meshList.at(0);
|
||||
for (int i = 0; i < meshList.size(); ++i) {
|
||||
if (meshList.at(i) == _m) {
|
||||
if(i+1 < meshList.size())
|
||||
return meshList.at(i+1);
|
||||
return meshList.front();
|
||||
for (auto it = meshList.begin(); it != meshList.end(); ++it) {
|
||||
if (*it == _m) {
|
||||
auto next = it;
|
||||
next++;
|
||||
if(next != meshList.end())
|
||||
return *next;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RasterModel* MeshDocument::nextRaster(RasterModel* _rm)
|
||||
{
|
||||
for (int i = 0; i < rasterList.size(); ++i) {
|
||||
if (rasterList.at(i) == _rm)
|
||||
{
|
||||
if(i+1 < rasterList.size())
|
||||
return rasterList.at(i+1);
|
||||
if(_rm==0 && rasterList.size()>0)
|
||||
return rasterList.front();
|
||||
for (auto it = rasterList.begin(); it != rasterList.end(); ++it) {
|
||||
if (*it == _rm) {
|
||||
auto next = it;
|
||||
next++;
|
||||
if(next != rasterList.end())
|
||||
return *next;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MeshModel* MeshDocument::mm()
|
||||
@ -367,10 +372,13 @@ std::list<MeshModel*> MeshDocument::getMeshesLoadedFromSameFile(MeshModel* mm)
|
||||
|
||||
bool MeshDocument::delMesh(MeshModel *mmToDel)
|
||||
{
|
||||
if(!meshList.removeOne(mmToDel))
|
||||
auto pos = std::find(meshList.begin(), meshList.end(), mmToDel);
|
||||
if (pos == meshList.end())
|
||||
return false;
|
||||
meshList.erase(pos);
|
||||
|
||||
if((currentMesh == mmToDel) && (!meshList.empty()))
|
||||
setCurrentMesh(this->meshList.at(0)->id());
|
||||
setCurrentMesh(this->meshList.front()->id());
|
||||
else if (meshList.empty())
|
||||
setCurrentMesh(-1);
|
||||
|
||||
@ -403,26 +411,17 @@ RasterModel * MeshDocument::addNewRaster(/*QString fullPathFilename*/)
|
||||
|
||||
bool MeshDocument::delRaster(RasterModel *rasterToDel)
|
||||
{
|
||||
QMutableListIterator<RasterModel *> i(rasterList);
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
RasterModel *r = i.next();
|
||||
|
||||
if (r==rasterToDel)
|
||||
{
|
||||
i.remove();
|
||||
delete rasterToDel;
|
||||
}
|
||||
}
|
||||
|
||||
if(currentRaster == rasterToDel)
|
||||
{
|
||||
if (!rasterList.empty())
|
||||
setCurrentRaster(rasterList.at(0)->id());
|
||||
else
|
||||
setCurrentRaster(-1);
|
||||
}
|
||||
auto pos = std::find(rasterList.begin(), rasterList.end(), rasterToDel);
|
||||
if (pos == rasterList.end())
|
||||
return false;
|
||||
rasterList.erase(pos);
|
||||
|
||||
if((currentRaster == rasterToDel) && (!rasterList.empty()))
|
||||
setCurrentRaster(this->rasterList.front()->id());
|
||||
else if (rasterList.empty())
|
||||
setCurrentRaster(-1);
|
||||
|
||||
delete rasterToDel;
|
||||
emit rasterSetChanged();
|
||||
|
||||
return true;
|
||||
|
||||
@ -114,8 +114,8 @@ public:
|
||||
{
|
||||
friend class MeshDocument;
|
||||
public:
|
||||
QList<MeshModel*>::iterator begin() {return md->meshList.begin();}
|
||||
QList<MeshModel*>::iterator end() {return md->meshList.end();}
|
||||
std::list<MeshModel*>::iterator begin() {return md->meshList.begin();}
|
||||
std::list<MeshModel*>::iterator end() {return md->meshList.end();}
|
||||
private:
|
||||
MeshRangeIterator(MeshDocument* md) : md(md){}
|
||||
MeshDocument* md;
|
||||
@ -128,9 +128,9 @@ public:
|
||||
|
||||
/// The very important member:
|
||||
/// The list of MeshModels.
|
||||
QList<MeshModel *> meshList;
|
||||
std::list<MeshModel *> meshList;
|
||||
/// The list of the raster models of the project
|
||||
QList<RasterModel *> rasterList;
|
||||
std::list<RasterModel *> rasterList;
|
||||
|
||||
private:
|
||||
int meshIdCounter;
|
||||
|
||||
@ -173,7 +173,7 @@ private:
|
||||
public:
|
||||
void Clear();
|
||||
void UpdateBoxAndNormals(); // This is the STANDARD method that you should call after changing coords.
|
||||
inline int id() const {return _id;}
|
||||
inline unsigned int id() const {return _id;}
|
||||
|
||||
int idInFile() const {return idInsideFile;}
|
||||
void setIdInFile(int id) {idInsideFile = id;}
|
||||
|
||||
@ -1110,7 +1110,7 @@ void LayerDialog::updatePerMeshItemVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
if ((!md->meshList.isEmpty()) && allhidden)
|
||||
if ((!md->meshList.empty()) && allhidden)
|
||||
_docitem->setIcon(0,QIcon(":/images/layer_eye_close.png"));
|
||||
else
|
||||
_docitem->setIcon(0,QIcon(":/images/layer_eye_open.png"));
|
||||
|
||||
@ -746,9 +746,8 @@ void MainWindow::endEdit()
|
||||
return;
|
||||
|
||||
|
||||
for (int ii = 0; ii < meshDoc()->meshList.size(); ++ii)
|
||||
for (MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mm = meshDoc()->meshList[ii];
|
||||
if (mm != NULL)
|
||||
addRenderingDataIfNewlyGeneratedMesh(mm->id());
|
||||
}
|
||||
@ -839,9 +838,8 @@ void MainWindow::runFilterScript()
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int ii = 0;ii < meshDoc()->meshList.size();++ii)
|
||||
for(MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mm = meshDoc()->meshList[ii];
|
||||
MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(mm);
|
||||
if ((pm != MLRenderingData::PR_ARITY) && (mm != NULL))
|
||||
{
|
||||
@ -1157,7 +1155,7 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms,
|
||||
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
MainWindow::globalStatusBar()->showMessage("Starting Filter...",5000);
|
||||
int req=iFilter->getRequirements(action);
|
||||
if (!meshDoc()->meshList.isEmpty())
|
||||
if (!meshDoc()->meshList.empty())
|
||||
meshDoc()->mm()->updateDataMask(req);
|
||||
qApp->restoreOverrideCursor();
|
||||
|
||||
@ -1200,9 +1198,8 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms,
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int ii = 0;ii < meshDoc()->meshList.size();++ii)
|
||||
for(MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mm = meshDoc()->meshList[ii];
|
||||
MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(mm);
|
||||
if ((pm != MLRenderingData::PR_ARITY) && (mm != NULL))
|
||||
{
|
||||
@ -1688,12 +1685,11 @@ void MainWindow::saveProject()
|
||||
|
||||
if (saveAllFile->isChecked())
|
||||
{
|
||||
for(int ii = 0; ii < meshDoc()->meshList.size();++ii)
|
||||
for(MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mp = meshDoc()->meshList[ii];
|
||||
if((!onlyVisibleLayers->isChecked()) || (mp->visible))
|
||||
if((!onlyVisibleLayers->isChecked()) || (mm->visible))
|
||||
{
|
||||
ret |= exportMesh(mp->fullName(),mp,true);
|
||||
ret |= exportMesh(mm->fullName(),mm,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1768,16 +1764,16 @@ bool MainWindow::openProject(QString fileName)
|
||||
return false;
|
||||
}
|
||||
GLA()->updateMeshSetVisibilities();
|
||||
for (int i=0; i<meshDoc()->meshList.size(); i++)
|
||||
for (MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
QString fullPath = meshDoc()->meshList[i]->fullName();
|
||||
QString fullPath = mm->fullName();
|
||||
//meshDoc()->setBusy(true);
|
||||
Matrix44m trm = this->meshDoc()->meshList[i]->cm.Tr; // save the matrix, because loadMeshClear it...
|
||||
Matrix44m trm = mm->cm.Tr; // save the matrix, because loadMeshClear it...
|
||||
MLRenderingData* ptr = NULL;
|
||||
if (rendOpt.find(meshDoc()->meshList[i]->id()) != rendOpt.end())
|
||||
ptr = &rendOpt[meshDoc()->meshList[i]->id()];
|
||||
if (!loadMeshWithStandardParams(fullPath, this->meshDoc()->meshList[i], trm, false, ptr))
|
||||
meshDoc()->delMesh(meshDoc()->meshList[i]);
|
||||
if (rendOpt.find(mm->id()) != rendOpt.end())
|
||||
ptr = &rendOpt[mm->id()];
|
||||
if (!loadMeshWithStandardParams(fullPath, mm, trm, false, ptr))
|
||||
meshDoc()->delMesh(mm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1914,16 +1910,20 @@ bool MainWindow::appendProject(QString fileName)
|
||||
return false;
|
||||
}
|
||||
GLA()->updateMeshSetVisibilities();
|
||||
for (int i = alreadyLoadedNum; i<meshDoc()->meshList.size(); i++)
|
||||
auto it = meshDoc()->meshList.begin();
|
||||
std::advance(it, alreadyLoadedNum);
|
||||
for (unsigned int i = alreadyLoadedNum; i<meshDoc()->meshList.size(); i++)
|
||||
{
|
||||
QString fullPath = meshDoc()->meshList[i]->fullName();
|
||||
MeshModel* mm = *it;
|
||||
QString fullPath = mm->fullName();
|
||||
meshDoc()->setBusy(true);
|
||||
Matrix44m trm = this->meshDoc()->meshList[i]->cm.Tr; // save the matrix, because loadMeshClear it...
|
||||
Matrix44m trm = mm->cm.Tr; // save the matrix, because loadMeshClear it...
|
||||
MLRenderingData* ptr = NULL;
|
||||
if (rendOpt.find(meshDoc()->meshList[i]->id()) != rendOpt.end())
|
||||
ptr = &rendOpt[meshDoc()->meshList[i]->id()];
|
||||
if(!loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i],trm, false, ptr))
|
||||
meshDoc()->delMesh(meshDoc()->meshList[i]);
|
||||
if (rendOpt.find(mm->id()) != rendOpt.end())
|
||||
ptr = &rendOpt[mm->id()];
|
||||
if(!loadMeshWithStandardParams(fullPath,mm,trm, false, ptr))
|
||||
meshDoc()->delMesh(mm);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2034,10 +2034,9 @@ void MainWindow::documentUpdateRequested()
|
||||
{
|
||||
if (meshDoc() == NULL)
|
||||
return;
|
||||
for (int ii = 0; ii < meshDoc()->meshList.size(); ++ii)
|
||||
for (MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mm = meshDoc()->meshList[ii];
|
||||
if (mm != NULL)
|
||||
if (mm != nullptr)
|
||||
{
|
||||
addRenderingDataIfNewlyGeneratedMesh(mm->id());
|
||||
updateLayerDialog();
|
||||
@ -3299,9 +3298,8 @@ void MainWindow::updateRenderingDataAccordingToActionsToAllVisibleLayers(const Q
|
||||
{
|
||||
if (meshDoc() == NULL)
|
||||
return;
|
||||
for (int ii = 0; ii < meshDoc()->meshList.size(); ++ii)
|
||||
for (MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mm = meshDoc()->meshList[ii];
|
||||
if ((mm != NULL) && (mm->isVisible()))
|
||||
{
|
||||
updateRenderingDataAccordingToActionsCommonCode(mm->id(), acts);
|
||||
@ -3329,10 +3327,10 @@ void MainWindow::updateRenderingDataAccordingToActions(int /*meshid*/, MLRenderi
|
||||
}
|
||||
}
|
||||
|
||||
for (int hh = 0; hh < meshDoc()->meshList.size(); ++hh)
|
||||
for (MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
if (meshDoc()->meshList[hh] != NULL)
|
||||
updateRenderingDataAccordingToActionsCommonCode(meshDoc()->meshList[hh]->id(), tmpacts);
|
||||
if (mm != NULL)
|
||||
updateRenderingDataAccordingToActionsCommonCode(mm->id(), tmpacts);
|
||||
}
|
||||
|
||||
for (int ii = 0; ii < tmpacts.size(); ++ii)
|
||||
@ -3384,9 +3382,8 @@ void MainWindow::updateRenderingDataAccordingToActionToAllVisibleLayers(MLRender
|
||||
if (meshDoc() == NULL)
|
||||
return;
|
||||
|
||||
for (int ii = 0; ii < meshDoc()->meshList.size(); ++ii)
|
||||
for (MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mm = meshDoc()->meshList[ii];
|
||||
if ((mm != NULL) && (mm->isVisible()))
|
||||
{
|
||||
updateRenderingDataAccordingToActionCommonCode(mm->id(), act);
|
||||
@ -3402,9 +3399,8 @@ void MainWindow::updateRenderingDataAccordingToActions(QList<MLRenderingGlobalA
|
||||
if (meshDoc() == NULL)
|
||||
return;
|
||||
|
||||
for (int ii = 0; ii < meshDoc()->meshList.size(); ++ii)
|
||||
for (MeshModel* mm : meshDoc()->meshList)
|
||||
{
|
||||
MeshModel* mm = meshDoc()->meshList[ii];
|
||||
if (mm != NULL)
|
||||
{
|
||||
foreach(MLRenderingGlobalAction* act, actlist)
|
||||
|
||||
@ -1076,12 +1076,14 @@ MeshWidget::MeshWidget(QWidget *p, const RichMesh& rpar, const RichMesh& rdef) :
|
||||
//defaultMeshIndex = -1;
|
||||
|
||||
int currentmeshindex = -1;
|
||||
for(unsigned int i=0; i< (unsigned int)md->meshList.size(); ++i) {
|
||||
QString shortName = md->meshList.at(i)->label();
|
||||
unsigned int i = 0;
|
||||
for(MeshModel* mm : md->meshList) {
|
||||
QString shortName = mm->label();
|
||||
meshNames.push_back(shortName);
|
||||
if((unsigned int) md->meshList.at(i)->id() == rp->value().getMeshId()) {
|
||||
if((unsigned int) mm->id() == rp->value().getMeshId()) {
|
||||
currentmeshindex = i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
Init(p,currentmeshindex,meshNames);
|
||||
@ -1090,33 +1092,41 @@ MeshWidget::MeshWidget(QWidget *p, const RichMesh& rpar, const RichMesh& rdef) :
|
||||
MeshModel * MeshWidget::getMesh()
|
||||
{
|
||||
//test to make sure index is in bounds
|
||||
int index = enumCombo->currentIndex();
|
||||
unsigned int index = enumCombo->currentIndex();
|
||||
if(index < md->meshList.size() && index > -1) {
|
||||
return md->meshList.at(enumCombo->currentIndex());
|
||||
auto it = md->meshList.begin();
|
||||
std::advance(it, index);
|
||||
return *it;
|
||||
}
|
||||
else return NULL;
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
void MeshWidget::setMesh(MeshModel * newMesh)
|
||||
{
|
||||
for(int i=0; i < md->meshList.size(); ++i) {
|
||||
if(md->meshList.at(i) == newMesh)
|
||||
unsigned int i = 0;
|
||||
for(MeshModel* mm : md->meshList) {
|
||||
if(mm == newMesh)
|
||||
setIndex(i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void MeshWidget::collectWidgetValue()
|
||||
{
|
||||
rp->setValue(MeshValue(md->meshList.at(enumCombo->currentIndex())->id()));
|
||||
auto it = md->meshList.begin();
|
||||
std::advance(it, enumCombo->currentIndex());
|
||||
rp->setValue(MeshValue((*it)->id()));
|
||||
}
|
||||
|
||||
void MeshWidget::resetWidgetValue()
|
||||
{
|
||||
int meshindex = -1;
|
||||
for(unsigned int i=0; i<(unsigned int)md->meshList.size(); ++i) {
|
||||
if((unsigned int) md->meshList.at(i)->id() == rp->value().getMeshId()) {
|
||||
unsigned int i = 0;
|
||||
for(MeshModel* mm : md->meshList) {
|
||||
if(mm->id() == rp->value().getMeshId()) {
|
||||
meshindex = i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
enumCombo->setCurrentIndex(meshindex);
|
||||
}
|
||||
@ -1124,10 +1134,12 @@ void MeshWidget::resetWidgetValue()
|
||||
void MeshWidget::setWidgetValue( const Value& nv )
|
||||
{
|
||||
int meshindex = -1;
|
||||
for(unsigned int i=0; i< (unsigned int)md->meshList.size(); ++i) {
|
||||
if((unsigned int) md->meshList.at(i)->id() == nv.getMeshId()) {
|
||||
unsigned int i = 0;
|
||||
for(MeshModel* mm : md->meshList) {
|
||||
if(mm->id() == nv.getMeshId()) {
|
||||
meshindex = i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
enumCombo->setCurrentIndex(meshindex);
|
||||
}
|
||||
|
||||
@ -188,11 +188,11 @@ RichParameterList FilterCameraPlugin::initParameterList(const QAction *action, c
|
||||
// Core Function doing the actual mesh processing.
|
||||
std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *filter, const RichParameterList & par, MeshDocument &md, unsigned int& /*postConditionMask*/, vcg::CallBackPos * /*cb*/)
|
||||
{
|
||||
MeshModel* mesh = md.mm();
|
||||
MeshModel* currentMesh = md.mm();
|
||||
CMeshO* cm = NULL;
|
||||
if (mesh != NULL)
|
||||
cm = &(mesh->cm);
|
||||
RasterModel *rm = md.rm();
|
||||
if (currentMesh != NULL)
|
||||
cm = &(currentMesh->cm);
|
||||
RasterModel *currentRaster = md.rm();
|
||||
switch(ID(filter))
|
||||
{
|
||||
case FP_CAMERA_ROTATE :
|
||||
@ -226,11 +226,11 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
switch(par.getEnum("camera"))
|
||||
{
|
||||
case 0:
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
tranVec=rm->shot.Extrinsics.Tra();
|
||||
tranVec=currentRaster->shot.Extrinsics.Tra();
|
||||
break;
|
||||
case 1:
|
||||
if (cm == NULL)
|
||||
@ -256,43 +256,43 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
Matrix44m transf=trTran*trRot*trTranInv;
|
||||
if (par.getBool("toall"))
|
||||
{
|
||||
for (int i=0; i<md.meshList.size(); i++)
|
||||
for (MeshModel* mm : md.meshIterator())
|
||||
{
|
||||
if (md.meshList[i]->visible)
|
||||
if (mm->visible)
|
||||
{
|
||||
md.meshList[i]->cm.Tr=transf * md.meshList[i]->cm.Tr;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(md.meshList[i]->cm, md.meshList[i]->cm.Tr);
|
||||
mm->cm.Tr=transf * mm->cm.Tr;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(mm->cm, mm->cm.Tr);
|
||||
//tri::UpdateNormal<CMeshO>::PerVertexMatrix(md.meshList[i]->cm,md.meshList[i]->cm.Tr);
|
||||
//tri::UpdateNormal<CMeshO>::PerFaceMatrix(md.meshList[i]->cm,md.meshList[i]->cm.Tr);
|
||||
tri::UpdateBounding<CMeshO>::Box(md.meshList[i]->cm);
|
||||
md.meshList[i]->cm.shot.ApplyRigidTransformation(transf);
|
||||
md.meshList[i]->cm.Tr.SetIdentity();
|
||||
tri::UpdateBounding<CMeshO>::Box(mm->cm);
|
||||
mm->cm.shot.ApplyRigidTransformation(transf);
|
||||
mm->cm.Tr.SetIdentity();
|
||||
}
|
||||
|
||||
}
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(transf);
|
||||
if (rm->visible)
|
||||
rm->shot.ApplyRigidTransformation(transf);
|
||||
}
|
||||
}
|
||||
else if (par.getBool("toallRaster") && (par.getEnum("camera")==0))
|
||||
{
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(transf);
|
||||
if (rm->visible)
|
||||
rm->shot.ApplyRigidTransformation(transf);
|
||||
}
|
||||
}
|
||||
else switch(par.getEnum("camera"))
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
rm->shot.ApplyRigidTransformation(transf);
|
||||
currentRaster->shot.ApplyRigidTransformation(transf);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
@ -327,11 +327,11 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
switch(par.getEnum("camera"))
|
||||
{
|
||||
case 0:
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
tranVec=rm->shot.Extrinsics.Tra();
|
||||
tranVec=currentRaster->shot.Extrinsics.Tra();
|
||||
break;
|
||||
case 1:
|
||||
if (cm == NULL)
|
||||
@ -352,41 +352,41 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
trTranInv.SetTranslate(-tranVec);
|
||||
if (par.getBool("toall"))
|
||||
{
|
||||
for (int i=0; i<md.meshList.size(); i++)
|
||||
for (MeshModel* mm : md.meshIterator())
|
||||
{
|
||||
if (md.meshList[i]->visible)
|
||||
if (mm->visible)
|
||||
{
|
||||
md.meshList[i]->cm.Tr=trTran*trScale*trTranInv;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(md.meshList[i]->cm, md.meshList[i]->cm.Tr);
|
||||
mm->cm.Tr=trTran*trScale*trTranInv;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(mm->cm, mm->cm.Tr);
|
||||
//tri::UpdateNormal<CMeshO>::PerVertexMatrix(md.meshList[i]->cm,md.meshList[i]->cm.Tr);
|
||||
//tri::UpdateNormal<CMeshO>::PerFaceMatrix(md.meshList[i]->cm,md.meshList[i]->cm.Tr);
|
||||
tri::UpdateBounding<CMeshO>::Box(md.meshList[i]->cm);
|
||||
md.meshList[i]->cm.Tr.SetIdentity();
|
||||
md.meshList[i]->cm.shot.ApplyRigidTransformation(trTran);
|
||||
md.meshList[i]->cm.shot.RescalingWorld(trScale[0][0], false);
|
||||
md.meshList[i]->cm.shot.ApplyRigidTransformation(trTranInv);
|
||||
tri::UpdateBounding<CMeshO>::Box(mm->cm);
|
||||
mm->cm.Tr.SetIdentity();
|
||||
mm->cm.shot.ApplyRigidTransformation(trTran);
|
||||
mm->cm.shot.RescalingWorld(trScale[0][0], false);
|
||||
mm->cm.shot.ApplyRigidTransformation(trTranInv);
|
||||
}
|
||||
|
||||
}
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
if (rm->visible)
|
||||
{
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(trTran);
|
||||
md.rasterList[i]->shot.RescalingWorld(trScale[0][0], false);
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(trTranInv);
|
||||
rm->shot.ApplyRigidTransformation(trTran);
|
||||
rm->shot.RescalingWorld(trScale[0][0], false);
|
||||
rm->shot.ApplyRigidTransformation(trTranInv);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (par.getBool("toallRaster") && (par.getEnum("camera")==0))
|
||||
{
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
if (rm->visible)
|
||||
{
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(trTran);
|
||||
md.rasterList[i]->shot.RescalingWorld(trScale[0][0], false);
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(trTranInv);
|
||||
rm->shot.ApplyRigidTransformation(trTran);
|
||||
rm->shot.RescalingWorld(trScale[0][0], false);
|
||||
rm->shot.ApplyRigidTransformation(trTranInv);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -394,13 +394,13 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
rm->shot.ApplyRigidTransformation(trTran);
|
||||
rm->shot.RescalingWorld(Scale, false);
|
||||
rm->shot.ApplyRigidTransformation(trTranInv);
|
||||
currentRaster->shot.ApplyRigidTransformation(trTran);
|
||||
currentRaster->shot.RescalingWorld(Scale, false);
|
||||
currentRaster->shot.ApplyRigidTransformation(trTranInv);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
@ -432,11 +432,11 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
switch(par.getEnum("camera"))
|
||||
{
|
||||
case 0:
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
trTran.SetTranslate(-rm->shot.Extrinsics.Tra());
|
||||
trTran.SetTranslate(-currentRaster->shot.Extrinsics.Tra());
|
||||
break;
|
||||
case 1:
|
||||
if (cm == NULL)
|
||||
@ -449,43 +449,43 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
}
|
||||
if (par.getBool("toall"))
|
||||
{
|
||||
for (int i=0; i<md.meshList.size(); i++)
|
||||
for (MeshModel* mm : md.meshIterator())
|
||||
{
|
||||
if (md.meshList[i]->visible)
|
||||
if (mm->visible)
|
||||
{
|
||||
md.meshList[i]->cm.Tr=trTran;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(md.meshList[i]->cm, md.meshList[i]->cm.Tr);
|
||||
mm->cm.Tr=trTran;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(mm->cm, mm->cm.Tr);
|
||||
//tri::UpdateNormal<CMeshO>::PerVertexMatrix(md.meshList[i]->cm,md.meshList[i]->cm.Tr);
|
||||
//tri::UpdateNormal<CMeshO>::PerFaceMatrix(md.meshList[i]->cm,md.meshList[i]->cm.Tr);
|
||||
tri::UpdateBounding<CMeshO>::Box(md.meshList[i]->cm);
|
||||
md.meshList[i]->cm.Tr.SetIdentity();
|
||||
md.meshList[i]->cm.shot.ApplyRigidTransformation(trTran);
|
||||
tri::UpdateBounding<CMeshO>::Box(mm->cm);
|
||||
mm->cm.Tr.SetIdentity();
|
||||
mm->cm.shot.ApplyRigidTransformation(trTran);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(trTran);
|
||||
if (rm->visible)
|
||||
rm->shot.ApplyRigidTransformation(trTran);
|
||||
|
||||
}
|
||||
}
|
||||
else if (par.getBool("toallRaster") && (par.getEnum("camera")==0))
|
||||
{
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(trTran);
|
||||
if (rm->visible)
|
||||
rm->shot.ApplyRigidTransformation(trTran);
|
||||
}
|
||||
}
|
||||
else switch(par.getEnum("camera"))
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
rm->shot.ApplyRigidTransformation(trTran);
|
||||
currentRaster->shot.ApplyRigidTransformation(trTran);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
@ -509,12 +509,12 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
mat = par.getMatrix44("TransformMatrix");
|
||||
if(par.getEnum("behaviour") == 1)
|
||||
{
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
inv = rm->shot.Extrinsics.Rot();
|
||||
tra = inv * rm->shot.Extrinsics.Tra();
|
||||
inv = currentRaster->shot.Extrinsics.Rot();
|
||||
tra = inv * currentRaster->shot.Extrinsics.Tra();
|
||||
inv[0][3] = -tra[0];
|
||||
inv[1][3] = -tra[1];
|
||||
inv[2][3] = -tra[2];
|
||||
@ -524,42 +524,42 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
|
||||
if (par.getBool("toall"))
|
||||
{
|
||||
for (int i=0; i<md.meshList.size(); i++)
|
||||
for (MeshModel* mm : md.meshIterator())
|
||||
{
|
||||
if (md.meshList[i]->visible)
|
||||
if (mm->visible)
|
||||
{
|
||||
md.meshList[i]->cm.Tr = mat;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(md.meshList[i]->cm, md.meshList[i]->cm.Tr);
|
||||
mm->cm.Tr = mat;
|
||||
tri::UpdatePosition<CMeshO>::Matrix(mm->cm, mm->cm.Tr);
|
||||
//tri::UpdateNormal<CMeshO>::PerFaceMatrix(md.meshList[i]->cm,md.meshList[i]->cm.Tr);
|
||||
tri::UpdateBounding<CMeshO>::Box(md.meshList[i]->cm);
|
||||
md.meshList[i]->cm.Tr.SetIdentity();
|
||||
md.meshList[i]->cm.shot.ApplySimilarity(mat);
|
||||
tri::UpdateBounding<CMeshO>::Box(mm->cm);
|
||||
mm->cm.Tr.SetIdentity();
|
||||
mm->cm.shot.ApplySimilarity(mat);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
md.rasterList[i]->shot.ApplySimilarity(mat);
|
||||
if (rm->visible)
|
||||
rm->shot.ApplySimilarity(mat);
|
||||
|
||||
}
|
||||
}
|
||||
else if (par.getBool("toallRaster") && (par.getEnum("camera")==0))
|
||||
{
|
||||
for (int i=0; i<md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
md.rasterList[i]->shot.ApplySimilarity(mat);
|
||||
if (rm->visible)
|
||||
rm->shot.ApplySimilarity(mat);
|
||||
}
|
||||
}
|
||||
else switch(par.getEnum("camera"))
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
rm->shot.ApplyRigidTransformation(mat);
|
||||
currentRaster->shot.ApplyRigidTransformation(mat);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
@ -578,19 +578,19 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
|
||||
case FP_SET_RASTER_CAMERA :
|
||||
{
|
||||
if (rm == NULL)
|
||||
if (currentRaster == NULL)
|
||||
{
|
||||
throw MLException("You need a Raster Model to apply this filter!");
|
||||
}
|
||||
Shotm shotGot=par.getShotf("Shot");
|
||||
rm->shot = shotGot;
|
||||
float ratio=(float)rm->currentPlane->image.height()/(float)shotGot.Intrinsics.ViewportPx[1];
|
||||
rm->shot.Intrinsics.ViewportPx[0]=rm->currentPlane->image.width();
|
||||
rm->shot.Intrinsics.ViewportPx[1]=rm->currentPlane->image.height();
|
||||
rm->shot.Intrinsics.PixelSizeMm[1]/=ratio;
|
||||
rm->shot.Intrinsics.PixelSizeMm[0]/=ratio;
|
||||
rm->shot.Intrinsics.CenterPx[0]=(int)((float)rm->shot.Intrinsics.ViewportPx[0]/2.0);
|
||||
rm->shot.Intrinsics.CenterPx[1]=(int)((float)rm->shot.Intrinsics.ViewportPx[1]/2.0);
|
||||
currentRaster->shot = shotGot;
|
||||
float ratio=(float)currentRaster->currentPlane->image.height()/(float)shotGot.Intrinsics.ViewportPx[1];
|
||||
currentRaster->shot.Intrinsics.ViewportPx[0]=currentRaster->currentPlane->image.width();
|
||||
currentRaster->shot.Intrinsics.ViewportPx[1]=currentRaster->currentPlane->image.height();
|
||||
currentRaster->shot.Intrinsics.PixelSizeMm[1]/=ratio;
|
||||
currentRaster->shot.Intrinsics.PixelSizeMm[0]/=ratio;
|
||||
currentRaster->shot.Intrinsics.CenterPx[0]=(int)((float)currentRaster->shot.Intrinsics.ViewportPx[0]/2.0);
|
||||
currentRaster->shot.Intrinsics.CenterPx[1]=(int)((float)currentRaster->shot.Intrinsics.ViewportPx[1]/2.0);
|
||||
}
|
||||
break;
|
||||
case FP_SET_MESH_CAMERA :
|
||||
@ -657,9 +657,11 @@ std::map<std::string, QVariant> FilterCameraPlugin::applyFilter(const QAction *f
|
||||
for(CMeshO::VertexIterator vi= cm->vert.begin(); vi != cm->vert.end();++vi)
|
||||
{
|
||||
unsigned int camera_id = ch[*vi][0].id_img;
|
||||
if (md.rasterList[camera_id] != NULL)
|
||||
auto it = md.rasterList.begin();
|
||||
std::advance(it, camera_id);
|
||||
if (it != md.rasterList.end() && *it != nullptr)
|
||||
{
|
||||
Point3m n=md.rasterList[camera_id]->shot.GetViewPoint()-(*vi).P() ;
|
||||
Point3m n=(*it)->shot.GetViewPoint()-(*vi).P() ;
|
||||
if( n*(*vi).cN()<0)
|
||||
(*vi). N()=-(*vi).cN();
|
||||
}
|
||||
|
||||
@ -403,16 +403,18 @@ std::map<std::string, QVariant> FilterColorProjectionPlugin::applyFilter(const Q
|
||||
allcammaxdepth = -1000000;
|
||||
allcammindepth = 1000000;
|
||||
allcammaximagesize = -1000000;
|
||||
for(cam_ind = 0; cam_ind < md.rasterList.size(); cam_ind++)
|
||||
cam_ind = 0;
|
||||
for(RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if(my_far[cam_ind] > allcammaxdepth)
|
||||
allcammaxdepth = my_far[cam_ind];
|
||||
if(my_near[cam_ind] < allcammindepth)
|
||||
allcammindepth = my_near[cam_ind];
|
||||
|
||||
float imgdiag = sqrt(double(md.rasterList[cam_ind]->shot.Intrinsics.ViewportPx[0] * md.rasterList[cam_ind]->shot.Intrinsics.ViewportPx[1]));
|
||||
float imgdiag = sqrt(double(rm->shot.Intrinsics.ViewportPx[0] * rm->shot.Intrinsics.ViewportPx[1]));
|
||||
if (imgdiag > allcammaximagesize)
|
||||
allcammaximagesize = imgdiag;
|
||||
cam_ind++;
|
||||
}
|
||||
|
||||
//-- cycle all cameras
|
||||
@ -718,16 +720,18 @@ std::map<std::string, QVariant> FilterColorProjectionPlugin::applyFilter(const Q
|
||||
allcammaxdepth = -1000000;
|
||||
allcammindepth = 1000000;
|
||||
allcammaximagesize = -1000000;
|
||||
for(cam_ind = 0; cam_ind < md.rasterList.size(); cam_ind++)
|
||||
cam_ind = 0;
|
||||
for(RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if(my_far[cam_ind] > allcammaxdepth)
|
||||
allcammaxdepth = my_far[cam_ind];
|
||||
if(my_near[cam_ind] < allcammindepth)
|
||||
allcammindepth = my_near[cam_ind];
|
||||
|
||||
float imgdiag = sqrt(double(md.rasterList[cam_ind]->shot.Intrinsics.ViewportPx[0] * md.rasterList[cam_ind]->shot.Intrinsics.ViewportPx[1]));
|
||||
float imgdiag = sqrt(double(rm->shot.Intrinsics.ViewportPx[0] * rm->shot.Intrinsics.ViewportPx[1]));
|
||||
if (imgdiag > allcammaximagesize)
|
||||
allcammaximagesize = imgdiag;
|
||||
cam_ind++;
|
||||
}
|
||||
|
||||
//-- cycle all cameras
|
||||
|
||||
@ -217,16 +217,14 @@ void FilterFractal::initParameterSetForFractalDisplacement(const QAction *filter
|
||||
|
||||
void FilterFractal::initParameterSetForCratersGeneration(const MeshDocument &md, RichParameterList &par)
|
||||
{
|
||||
int meshCount = md.meshList.size();
|
||||
|
||||
// tries to detect the target mesh
|
||||
const MeshModel* target = md.mm();
|
||||
const MeshModel* samples = md.mm();
|
||||
MeshModel* tmpMesh;
|
||||
if (samples->cm.fn != 0){ // this is probably not the samples layer
|
||||
for(int i=0; i<meshCount; i++)
|
||||
for(MeshModel* mm : md.meshList)
|
||||
{
|
||||
tmpMesh = md.meshList.at(i);
|
||||
tmpMesh = mm;
|
||||
if (tmpMesh->cm.fn == 0)
|
||||
{
|
||||
samples = tmpMesh;
|
||||
|
||||
@ -459,26 +459,26 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
}
|
||||
|
||||
int active = 0;
|
||||
for (int i = 0; i < md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
if (rm->visible)
|
||||
active++;
|
||||
}
|
||||
|
||||
fprintf(outfile, "# Bundle file v0.3\n");
|
||||
fprintf(outfile, "%d %d\n", active, 0);
|
||||
|
||||
for (int i = 0; i < md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
if (rm->visible)
|
||||
{
|
||||
fprintf(outfile, "%f %d %d\n", md.rasterList[i]->shot.Intrinsics.FocalMm / md.rasterList[i]->shot.Intrinsics.PixelSizeMm[0], 0, 0);
|
||||
fprintf(outfile, "%f %d %d\n", rm->shot.Intrinsics.FocalMm / rm->shot.Intrinsics.PixelSizeMm[0], 0, 0);
|
||||
|
||||
Matrix44m mat = md.rasterList[i]->shot.Extrinsics.Rot();
|
||||
Matrix44m mat = rm->shot.Extrinsics.Rot();
|
||||
|
||||
Matrix33m Rt = Matrix33m(Matrix44m(mat), 3);
|
||||
|
||||
Point3f pos = Rt * md.rasterList[i]->shot.Extrinsics.Tra();
|
||||
Point3f pos = Rt * rm->shot.Extrinsics.Tra();
|
||||
Rt.Transpose();
|
||||
|
||||
fprintf(outfile, "%f %f %f\n", Rt[0][0], Rt[1][0], Rt[2][0]);
|
||||
@ -515,22 +515,23 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
xmlWriter.writeStartElement("chunk");
|
||||
xmlWriter.writeStartElement("sensors");
|
||||
|
||||
for (int i = 0; i < md.rasterList.size(); i++)
|
||||
unsigned int i = 0;
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
if (rm->visible)
|
||||
{
|
||||
float focal, pixelX, pixelY;
|
||||
if (md.rasterList[i]->shot.Intrinsics.FocalMm > 1000)
|
||||
if (rm->shot.Intrinsics.FocalMm > 1000)
|
||||
{
|
||||
focal = md.rasterList[i]->shot.Intrinsics.FocalMm / 500;
|
||||
pixelX = md.rasterList[i]->shot.Intrinsics.PixelSizeMm[0] / 500;
|
||||
pixelY = md.rasterList[i]->shot.Intrinsics.PixelSizeMm[1] / 500;
|
||||
focal = rm->shot.Intrinsics.FocalMm / 500;
|
||||
pixelX = rm->shot.Intrinsics.PixelSizeMm[0] / 500;
|
||||
pixelY = rm->shot.Intrinsics.PixelSizeMm[1] / 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
focal = md.rasterList[i]->shot.Intrinsics.FocalMm;
|
||||
pixelX = md.rasterList[i]->shot.Intrinsics.PixelSizeMm[0];
|
||||
pixelY = md.rasterList[i]->shot.Intrinsics.PixelSizeMm[1];
|
||||
focal = rm->shot.Intrinsics.FocalMm;
|
||||
pixelX = rm->shot.Intrinsics.PixelSizeMm[0];
|
||||
pixelY = rm->shot.Intrinsics.PixelSizeMm[1];
|
||||
}
|
||||
|
||||
xmlWriter.writeStartElement("sensor");
|
||||
@ -538,8 +539,8 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
xmlWriter.writeAttribute("label", "unknown"+QString::number(i));
|
||||
xmlWriter.writeAttribute("type", "frame");
|
||||
xmlWriter.writeStartElement("resolution");
|
||||
xmlWriter.writeAttribute("width", QString::number(md.rasterList[i]->shot.Intrinsics.ViewportPx[0]));
|
||||
xmlWriter.writeAttribute("height", QString::number(md.rasterList[i]->shot.Intrinsics.ViewportPx[1]));
|
||||
xmlWriter.writeAttribute("width", QString::number(rm->shot.Intrinsics.ViewportPx[0]));
|
||||
xmlWriter.writeAttribute("height", QString::number(rm->shot.Intrinsics.ViewportPx[1]));
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeStartElement("property");
|
||||
xmlWriter.writeAttribute("name", "pixel_width");
|
||||
@ -561,13 +562,13 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
xmlWriter.writeAttribute("type", "frame");
|
||||
xmlWriter.writeAttribute("class", "adjusted");
|
||||
xmlWriter.writeStartElement("resolution");
|
||||
xmlWriter.writeAttribute("width", QString::number(md.rasterList[i]->shot.Intrinsics.ViewportPx[0]));
|
||||
xmlWriter.writeAttribute("height", QString::number(md.rasterList[i]->shot.Intrinsics.ViewportPx[1]));
|
||||
xmlWriter.writeAttribute("width", QString::number(rm->shot.Intrinsics.ViewportPx[0]));
|
||||
xmlWriter.writeAttribute("height", QString::number(rm->shot.Intrinsics.ViewportPx[1]));
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeTextElement("fx", QString::number(md.rasterList[i]->shot.Intrinsics.FocalMm / md.rasterList[i]->shot.Intrinsics.PixelSizeMm[0]));
|
||||
xmlWriter.writeTextElement("fy", QString::number(md.rasterList[i]->shot.Intrinsics.FocalMm / md.rasterList[i]->shot.Intrinsics.PixelSizeMm[1]));
|
||||
xmlWriter.writeTextElement("cx", QString::number(md.rasterList[i]->shot.Intrinsics.CenterPx[0]));
|
||||
xmlWriter.writeTextElement("cy", QString::number(md.rasterList[i]->shot.Intrinsics.CenterPx[1]));
|
||||
xmlWriter.writeTextElement("fx", QString::number(rm->shot.Intrinsics.FocalMm / rm->shot.Intrinsics.PixelSizeMm[0]));
|
||||
xmlWriter.writeTextElement("fy", QString::number(rm->shot.Intrinsics.FocalMm / rm->shot.Intrinsics.PixelSizeMm[1]));
|
||||
xmlWriter.writeTextElement("cx", QString::number(rm->shot.Intrinsics.CenterPx[0]));
|
||||
xmlWriter.writeTextElement("cy", QString::number(rm->shot.Intrinsics.CenterPx[1]));
|
||||
xmlWriter.writeTextElement("k1", "0");
|
||||
xmlWriter.writeTextElement("k2", "0");
|
||||
xmlWriter.writeTextElement("p1", "0");
|
||||
@ -575,20 +576,22 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
}
|
||||
++i;
|
||||
}
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeStartElement("cameras");
|
||||
for (int i = 0; i < md.rasterList.size(); i++)
|
||||
i = 0;
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
if (rm->visible)
|
||||
{
|
||||
xmlWriter.writeStartElement("camera");
|
||||
xmlWriter.writeAttribute("id", QString::number(i));
|
||||
xmlWriter.writeAttribute("label", md.rasterList[i]->currentPlane->shortName());
|
||||
xmlWriter.writeAttribute("label", rm->currentPlane->shortName());
|
||||
xmlWriter.writeAttribute("sensor_id", QString::number(i));
|
||||
xmlWriter.writeAttribute("enabled", "true");
|
||||
Matrix44m mat = md.rasterList[i]->shot.Extrinsics.Rot();
|
||||
Point3f pos = md.rasterList[i]->shot.Extrinsics.Tra();
|
||||
Matrix44m mat = rm->shot.Extrinsics.Rot();
|
||||
Point3f pos = rm->shot.Extrinsics.Tra();
|
||||
QString transform= QString::number(mat[0][0]);
|
||||
transform.append(" " + QString::number(-mat[1][0]));
|
||||
transform.append(" " + QString::number(-mat[2][0]));
|
||||
@ -609,6 +612,7 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
xmlWriter.writeTextElement("transform", transform);
|
||||
xmlWriter.writeEndElement();
|
||||
}
|
||||
++i;
|
||||
}
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndDocument();
|
||||
@ -647,9 +651,9 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
|
||||
///// Check if the number of active rasters and cameras is the same
|
||||
unsigned active = 0;
|
||||
for (int i = 0; i < md.rasterList.size(); i++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->visible)
|
||||
if (rm->visible)
|
||||
active++;
|
||||
}
|
||||
|
||||
@ -659,47 +663,51 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
}
|
||||
|
||||
//// Import cameras
|
||||
for (uint i = 0; i < num_cams; ++i)
|
||||
unsigned int i = 0;
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
float f, k1, k2;
|
||||
float R[16] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1 };
|
||||
vcg::Point3f t;
|
||||
if (rm->visible) {
|
||||
float f, k1, k2;
|
||||
float R[16] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1 };
|
||||
vcg::Point3f t;
|
||||
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &f, &k1, &k2);
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &f, &k1, &k2);
|
||||
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(R[0]), &(R[1]), &(R[2])); R[3] = 0;
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(R[4]), &(R[5]), &(R[6])); R[7] = 0;
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(R[8]), &(R[9]), &(R[10])); R[11] = 0;
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(R[0]), &(R[1]), &(R[2])); R[3] = 0;
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(R[4]), &(R[5]), &(R[6])); R[7] = 0;
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(R[8]), &(R[9]), &(R[10])); R[11] = 0;
|
||||
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(t[0]), &(t[1]), &(t[2]));
|
||||
fgets(line, 100, fp);; if (line[0] == '\0') throw MLException("Error while parsing " + fileName);;
|
||||
sscanf(line, "%f %f %f", &(t[0]), &(t[1]), &(t[2]));
|
||||
|
||||
Matrix44f matF(R);
|
||||
Matrix44m mat;
|
||||
mat.Import(matF);
|
||||
Matrix44f matF(R);
|
||||
Matrix44m mat;
|
||||
mat.Import(matF);
|
||||
|
||||
Matrix33m Rt = Matrix33m(Matrix44m(mat), 3);
|
||||
Rt.Transpose();
|
||||
Matrix33m Rt = Matrix33m(Matrix44m(mat), 3);
|
||||
Rt.Transpose();
|
||||
|
||||
Point3f pos = Rt * Point3f(t[0], t[1], t[2]);
|
||||
Point3f pos = Rt * Point3f(t[0], t[1], t[2]);
|
||||
|
||||
md.rasterList[i]->shot.Extrinsics.SetTra(Point3f(-pos[0], -pos[1], -pos[2]));
|
||||
md.rasterList[i]->shot.Extrinsics.SetRot(mat);
|
||||
rm->shot.Extrinsics.SetTra(Point3f(-pos[0], -pos[1], -pos[2]));
|
||||
rm->shot.Extrinsics.SetRot(mat);
|
||||
|
||||
md.rasterList[i]->shot.Intrinsics.FocalMm = f;
|
||||
md.rasterList[i]->shot.Intrinsics.k[0] = 0.0;//k1; To be uncommented when distortion is taken into account reliably
|
||||
md.rasterList[i]->shot.Intrinsics.k[1] = 0.0;//k2;
|
||||
md.rasterList[i]->shot.Intrinsics.PixelSizeMm = vcg::Point2f(1, 1);
|
||||
QSize size;
|
||||
QImageReader sizeImg(md.rasterList[i]->currentPlane->fullPathFileName);
|
||||
size = sizeImg.size();
|
||||
md.rasterList[i]->shot.Intrinsics.ViewportPx = vcg::Point2i(size.width(), size.height());
|
||||
md.rasterList[i]->shot.Intrinsics.CenterPx[0] = (int)((double)md.rasterList[i]->shot.Intrinsics.ViewportPx[0] / 2.0f);
|
||||
md.rasterList[i]->shot.Intrinsics.CenterPx[1] = (int)((double)md.rasterList[i]->shot.Intrinsics.ViewportPx[1] / 2.0f);
|
||||
rm->shot.Intrinsics.FocalMm = f;
|
||||
rm->shot.Intrinsics.k[0] = 0.0;//k1; To be uncommented when distortion is taken into account reliably
|
||||
rm->shot.Intrinsics.k[1] = 0.0;//k2;
|
||||
rm->shot.Intrinsics.PixelSizeMm = vcg::Point2f(1, 1);
|
||||
QSize size;
|
||||
QImageReader sizeImg(rm->currentPlane->fullPathFileName);
|
||||
size = sizeImg.size();
|
||||
rm->shot.Intrinsics.ViewportPx = vcg::Point2i(size.width(), size.height());
|
||||
rm->shot.Intrinsics.CenterPx[0] = (int)((double)rm->shot.Intrinsics.ViewportPx[0] / 2.0f);
|
||||
rm->shot.Intrinsics.CenterPx[1] = (int)((double)rm->shot.Intrinsics.ViewportPx[1] / 2.0f);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
else if ((fi.suffix().toLower() == "xml"))
|
||||
@ -794,33 +802,33 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
int sensor_id = n.attributes().namedItem("sensor_id").nodeValue().toInt();
|
||||
QString name = n.attributes().namedItem("label").nodeValue();
|
||||
|
||||
int rasterId = -1;
|
||||
for (int i = 0; i < md.rasterList.size(); i++)
|
||||
RasterModel* rasterId = nullptr;
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if (md.rasterList[i]->currentPlane->shortName() == name)
|
||||
if (rm->currentPlane->shortName() == name)
|
||||
{
|
||||
rasterId = i;
|
||||
rasterId = rm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QDomNode node = n.firstChild();
|
||||
|
||||
while (!node.isNull() && rasterId != -1)
|
||||
while (!node.isNull() && rasterId != nullptr)
|
||||
{
|
||||
if (QString::compare(node.nodeName(), "transform") == 0)
|
||||
{
|
||||
md.rasterList[rasterId]->shot.Intrinsics.FocalMm = shots[sensor_id].Intrinsics.FocalMm;
|
||||
md.rasterList[rasterId]->shot.Intrinsics.ViewportPx[0] = shots[sensor_id].Intrinsics.ViewportPx[0];
|
||||
md.rasterList[rasterId]->shot.Intrinsics.ViewportPx[1] = shots[sensor_id].Intrinsics.ViewportPx[1];
|
||||
md.rasterList[rasterId]->shot.Intrinsics.CenterPx[0] = shots[sensor_id].Intrinsics.CenterPx[0];
|
||||
md.rasterList[rasterId]->shot.Intrinsics.CenterPx[1] = shots[sensor_id].Intrinsics.CenterPx[1];
|
||||
md.rasterList[rasterId]->shot.Intrinsics.PixelSizeMm[0] = shots[sensor_id].Intrinsics.PixelSizeMm[0];
|
||||
md.rasterList[rasterId]->shot.Intrinsics.PixelSizeMm[1] = shots[sensor_id].Intrinsics.PixelSizeMm[1];
|
||||
rasterId->shot.Intrinsics.FocalMm = shots[sensor_id].Intrinsics.FocalMm;
|
||||
rasterId->shot.Intrinsics.ViewportPx[0] = shots[sensor_id].Intrinsics.ViewportPx[0];
|
||||
rasterId->shot.Intrinsics.ViewportPx[1] = shots[sensor_id].Intrinsics.ViewportPx[1];
|
||||
rasterId->shot.Intrinsics.CenterPx[0] = shots[sensor_id].Intrinsics.CenterPx[0];
|
||||
rasterId->shot.Intrinsics.CenterPx[1] = shots[sensor_id].Intrinsics.CenterPx[1];
|
||||
rasterId->shot.Intrinsics.PixelSizeMm[0] = shots[sensor_id].Intrinsics.PixelSizeMm[0];
|
||||
rasterId->shot.Intrinsics.PixelSizeMm[1] = shots[sensor_id].Intrinsics.PixelSizeMm[1];
|
||||
|
||||
QStringList values = node.toElement().text().split(" ", QString::SkipEmptyParts);
|
||||
Matrix44m mat = md.rasterList[i]->shot.Extrinsics.Rot();
|
||||
Point3f pos = md.rasterList[i]->shot.Extrinsics.Tra();
|
||||
Matrix44m mat = rasterId->shot.Extrinsics.Rot();
|
||||
Point3f pos = rasterId->shot.Extrinsics.Tra();
|
||||
|
||||
mat[0][0] = values[0].toFloat();
|
||||
mat[1][0] = -values[1].toFloat();
|
||||
@ -834,8 +842,8 @@ std::map<std::string, QVariant> FilterLayerPlugin::applyFilter(
|
||||
mat[1][2] = -values[9].toFloat();
|
||||
mat[2][2] = -values[10].toFloat();
|
||||
pos[2] = values[11].toFloat();
|
||||
md.rasterList[i]->shot.Extrinsics.SetRot(mat);
|
||||
md.rasterList[i]->shot.Extrinsics.SetTra(pos);
|
||||
rasterId->shot.Extrinsics.SetRot(mat);
|
||||
rasterId->shot.Extrinsics.SetTra(pos);
|
||||
}
|
||||
node = node.nextSibling();
|
||||
}
|
||||
|
||||
@ -669,9 +669,9 @@ void ApplyTransform(MeshDocument &md, const Matrix44m &tr, bool toAllFlag, bool
|
||||
if(freeze) Freeze(m);
|
||||
}
|
||||
|
||||
for (int i = 0; i < md.rasterList.size(); i++)
|
||||
if (md.rasterList[0]->visible)
|
||||
md.rasterList[i]->shot.ApplyRigidTransformation(tr);
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
if (rm->visible)
|
||||
rm->shot.ApplyRigidTransformation(tr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -196,9 +196,9 @@ std::map<std::string, QVariant> FilterMutualGlobal::applyFilter(
|
||||
myVec.push_back(md.mm()->cm.vert[i].P());
|
||||
}
|
||||
std::vector<Shotm> oldShots;
|
||||
for (int r=0; r<md.rasterList.size();r++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
oldShots.push_back(md.rasterList[r]->shot);
|
||||
oldShots.push_back(rm->shot);
|
||||
}
|
||||
|
||||
log("Sampled has %i vertices",myVec.size());
|
||||
@ -237,9 +237,9 @@ std::map<std::string, QVariant> FilterMutualGlobal::applyFilter(
|
||||
if (diff<thresDiff)
|
||||
break;
|
||||
oldShots.clear();
|
||||
for (int r=0; r<md.rasterList.size();r++)
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
oldShots.push_back(md.rasterList[r]->shot);
|
||||
oldShots.push_back(rm->shot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,15 +265,17 @@ float FilterMutualGlobal::calcShotsDifference(MeshDocument &md, std::vector<Shot
|
||||
std::vector<float> distances;
|
||||
for (int i=0; i<points.size(); i++)
|
||||
{
|
||||
for(int j=0; j<md.rasterList.size(); j++)
|
||||
unsigned int j = 0;
|
||||
for(RasterModel* rm : md.rasterList)
|
||||
{
|
||||
vcg::Point2f pp=md.rasterList[j]->shot.Project(points[i]);
|
||||
if(pp[0]>0 && pp[1]>0 && pp[0]<md.rasterList[j]->shot.Intrinsics.ViewportPx[0] && pp[1]<md.rasterList[j]->shot.Intrinsics.ViewportPx[1])
|
||||
vcg::Point2f pp=rm->shot.Project(points[i]);
|
||||
if(pp[0]>0 && pp[1]>0 && pp[0]<rm->shot.Intrinsics.ViewportPx[0] && pp[1]<rm->shot.Intrinsics.ViewportPx[1])
|
||||
{
|
||||
vcg::Point2f ppOld=oldShots[j].Project(points[i]);
|
||||
vcg::Point2f d=pp-ppOld;
|
||||
distances.push_back(vcg::math::Sqrt( d[0]*d[0] + d[1]*d[1] ));
|
||||
}
|
||||
++j;
|
||||
}
|
||||
}
|
||||
float totErr=0.0;
|
||||
@ -366,86 +368,87 @@ bool FilterMutualGlobal::preAlignment(MeshDocument &md, const RichParameterList
|
||||
MutualInfo mutual;
|
||||
if (md.rasterList.size()==0)
|
||||
{
|
||||
log("You need a Raster Model to apply this filter!");
|
||||
return false;
|
||||
log("You need a Raster Model to apply this filter!");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
alignset.mesh=&md.mm()->cm;
|
||||
alignset.mesh=&md.mm()->cm;
|
||||
|
||||
solver.optimize_focal=par.getBool("Estimate Focal");
|
||||
solver.fine_alignment=par.getBool("Fine");
|
||||
solver.optimize_focal=par.getBool("Estimate Focal");
|
||||
solver.fine_alignment=par.getBool("Fine");
|
||||
|
||||
int rendmode= par.getEnum("RenderingMode");
|
||||
int rendmode= par.getEnum("RenderingMode");
|
||||
|
||||
switch(rendmode){
|
||||
case 0:
|
||||
alignset.mode=AlignSet::COMBINE;
|
||||
break;
|
||||
case 1:
|
||||
alignset.mode=AlignSet::NORMALMAP;
|
||||
break;
|
||||
case 2:
|
||||
alignset.mode=AlignSet::COLOR;
|
||||
break;
|
||||
case 3:
|
||||
alignset.mode=AlignSet::SPECULAR;
|
||||
break;
|
||||
case 4:
|
||||
alignset.mode=AlignSet::SILHOUETTE;
|
||||
break;
|
||||
case 5:
|
||||
alignset.mode=AlignSet::SPECAMB;
|
||||
break;
|
||||
default:
|
||||
alignset.mode=AlignSet::COMBINE;
|
||||
break;
|
||||
}
|
||||
switch(rendmode){
|
||||
case 0:
|
||||
alignset.mode=AlignSet::COMBINE;
|
||||
break;
|
||||
case 1:
|
||||
alignset.mode=AlignSet::NORMALMAP;
|
||||
break;
|
||||
case 2:
|
||||
alignset.mode=AlignSet::COLOR;
|
||||
break;
|
||||
case 3:
|
||||
alignset.mode=AlignSet::SPECULAR;
|
||||
break;
|
||||
case 4:
|
||||
alignset.mode=AlignSet::SILHOUETTE;
|
||||
break;
|
||||
case 5:
|
||||
alignset.mode=AlignSet::SPECAMB;
|
||||
break;
|
||||
default:
|
||||
alignset.mode=AlignSet::COMBINE;
|
||||
break;
|
||||
}
|
||||
|
||||
vcg::Point3f *vertices = new vcg::Point3f[alignset.mesh->vn];
|
||||
vcg::Point3f *normals = new vcg::Point3f[alignset.mesh->vn];
|
||||
vcg::Color4b *colors = new vcg::Color4b[alignset.mesh->vn];
|
||||
unsigned int *indices = new unsigned int[alignset.mesh->fn*3];
|
||||
vcg::Point3f *vertices = new vcg::Point3f[alignset.mesh->vn];
|
||||
vcg::Point3f *normals = new vcg::Point3f[alignset.mesh->vn];
|
||||
vcg::Color4b *colors = new vcg::Color4b[alignset.mesh->vn];
|
||||
unsigned int *indices = new unsigned int[alignset.mesh->fn*3];
|
||||
|
||||
for(int i = 0; i < alignset.mesh->vn; i++) {
|
||||
vertices[i] = alignset.mesh->vert[i].P();
|
||||
normals[i] = alignset.mesh->vert[i].N();
|
||||
colors[i] = alignset.mesh->vert[i].C();
|
||||
}
|
||||
for(int i = 0; i < alignset.mesh->vn; i++) {
|
||||
vertices[i] = alignset.mesh->vert[i].P();
|
||||
normals[i] = alignset.mesh->vert[i].N();
|
||||
colors[i] = alignset.mesh->vert[i].C();
|
||||
}
|
||||
|
||||
for(int i = 0; i < alignset.mesh->fn; i++)
|
||||
for(int k = 0; k < 3; k++)
|
||||
indices[k+i*3] = alignset.mesh->face[i].V(k) - &*alignset.mesh->vert.begin();
|
||||
for(int i = 0; i < alignset.mesh->fn; i++)
|
||||
for(int k = 0; k < 3; k++)
|
||||
indices[k+i*3] = alignset.mesh->face[i].V(k) - &*alignset.mesh->vert.begin();
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.vbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Point3f),
|
||||
vertices, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.nbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Point3f),
|
||||
normals, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.cbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Color4b),
|
||||
colors, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.vbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Point3f),
|
||||
vertices, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.nbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Point3f),
|
||||
normals, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.cbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Color4b),
|
||||
colors, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, alignset.ibo);
|
||||
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, alignset.mesh->fn*3*sizeof(unsigned int),
|
||||
indices, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, alignset.ibo);
|
||||
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, alignset.mesh->fn*3*sizeof(unsigned int),
|
||||
indices, GL_STATIC_DRAW_ARB);
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
|
||||
// it is safe to delete after copying data to VBO
|
||||
delete []vertices;
|
||||
delete []normals;
|
||||
delete []colors;
|
||||
delete []indices;
|
||||
// it is safe to delete after copying data to VBO
|
||||
delete []vertices;
|
||||
delete []normals;
|
||||
delete []colors;
|
||||
delete []indices;
|
||||
|
||||
for (int r=0; r<md.rasterList.size();r++)
|
||||
{
|
||||
if(md.rasterList[r]->visible)
|
||||
unsigned int r = 0;
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
alignset.image=&md.rasterList[r]->currentPlane->image;
|
||||
alignset.shot=md.rasterList[r]->shot;
|
||||
if(rm->visible)
|
||||
{
|
||||
alignset.image=&rm->currentPlane->image;
|
||||
alignset.shot=rm->shot;
|
||||
|
||||
alignset.resize(800);
|
||||
|
||||
@ -453,27 +456,29 @@ bool FilterMutualGlobal::preAlignment(MeshDocument &md, const RichParameterList
|
||||
alignset.shot.Intrinsics.CenterPx[0]=(int)(alignset.shot.Intrinsics.ViewportPx[0]/2);
|
||||
|
||||
if (solver.fine_alignment)
|
||||
solver.optimize(&alignset, &mutual, alignset.shot);
|
||||
solver.optimize(&alignset, &mutual, alignset.shot);
|
||||
else
|
||||
{
|
||||
solver.iterative(&alignset, &mutual, alignset.shot);
|
||||
log("Vado di rough",r);
|
||||
solver.iterative(&alignset, &mutual, alignset.shot);
|
||||
log("Vado di rough",r);
|
||||
}
|
||||
|
||||
md.rasterList[r]->shot=alignset.shot;
|
||||
float ratio=(float)md.rasterList[r]->currentPlane->image.height()/(float)alignset.shot.Intrinsics.ViewportPx[1];
|
||||
md.rasterList[r]->shot.Intrinsics.ViewportPx[0]=md.rasterList[r]->currentPlane->image.width();
|
||||
md.rasterList[r]->shot.Intrinsics.ViewportPx[1]=md.rasterList[r]->currentPlane->image.height();
|
||||
md.rasterList[r]->shot.Intrinsics.PixelSizeMm[1]/=ratio;
|
||||
md.rasterList[r]->shot.Intrinsics.PixelSizeMm[0]/=ratio;
|
||||
md.rasterList[r]->shot.Intrinsics.CenterPx[0]=(int)((float)md.rasterList[r]->shot.Intrinsics.ViewportPx[0]/2.0);
|
||||
md.rasterList[r]->shot.Intrinsics.CenterPx[1]=(int)((float)md.rasterList[r]->shot.Intrinsics.ViewportPx[1]/2.0);
|
||||
rm->shot=alignset.shot;
|
||||
float ratio=(float)rm->currentPlane->image.height()/(float)alignset.shot.Intrinsics.ViewportPx[1];
|
||||
rm->shot.Intrinsics.ViewportPx[0]=rm->currentPlane->image.width();
|
||||
rm->shot.Intrinsics.ViewportPx[1]=rm->currentPlane->image.height();
|
||||
rm->shot.Intrinsics.PixelSizeMm[1]/=ratio;
|
||||
rm->shot.Intrinsics.PixelSizeMm[0]/=ratio;
|
||||
rm->shot.Intrinsics.CenterPx[0]=(int)((float)rm->shot.Intrinsics.ViewportPx[0]/2.0);
|
||||
rm->shot.Intrinsics.CenterPx[1]=(int)((float)rm->shot.Intrinsics.ViewportPx[1]/2.0);
|
||||
|
||||
log("Image %d completed",r);
|
||||
|
||||
}
|
||||
else
|
||||
log("Image %d skipped",r);
|
||||
}
|
||||
else{
|
||||
log("Image %d skipped",r);
|
||||
}
|
||||
++r;
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,13 +550,14 @@ std::vector<AlignPair> FilterMutualGlobal::CalcPairs(MeshDocument &md, bool glob
|
||||
//alignset.mode=AlignSet::PROJIMG;
|
||||
|
||||
//this->glContext->makeCurrent();
|
||||
for (int r=0; r<md.rasterList.size(); r++)
|
||||
unsigned int r = 0;
|
||||
for (RasterModel* rm : md.rasterList)
|
||||
{
|
||||
if(md.rasterList[r]->visible)
|
||||
if(rm->visible)
|
||||
{
|
||||
AlignPair pair;
|
||||
alignset.image=&md.rasterList[r]->currentPlane->image;
|
||||
alignset.shot=md.rasterList[r]->shot;
|
||||
alignset.image=&rm->currentPlane->image;
|
||||
alignset.shot=rm->shot;
|
||||
|
||||
//this->initGL();
|
||||
alignset.resize(800);
|
||||
@ -567,13 +573,14 @@ std::vector<AlignPair> FilterMutualGlobal::CalcPairs(MeshDocument &md, bool glob
|
||||
QImage covered=alignset.comb;
|
||||
std::vector<AlignPair> weightList;
|
||||
|
||||
for (int p=0; p<md.rasterList.size(); p++)
|
||||
unsigned int p = 0;
|
||||
for (RasterModel* pm : md.rasterList)
|
||||
{
|
||||
if (p!=r)
|
||||
if (pm!=rm)
|
||||
{
|
||||
alignset.mode=AlignSet::PROJIMG;
|
||||
alignset.shotPro=md.rasterList[p]->shot;
|
||||
alignset.imagePro=&md.rasterList[p]->currentPlane->image;
|
||||
alignset.shotPro=pm->shot;
|
||||
alignset.imagePro=&pm->currentPlane->image;
|
||||
alignset.ProjectedImageChanged(*alignset.imagePro);
|
||||
float countTot=0.0;
|
||||
float countCol=0.0;
|
||||
@ -595,18 +602,19 @@ std::vector<AlignPair> FilterMutualGlobal::CalcPairs(MeshDocument &md, bool glob
|
||||
}
|
||||
}
|
||||
}
|
||||
pair.area=countCol/countTot;
|
||||
pair.area=countCol/countTot;
|
||||
|
||||
if (pair.area>0.2)
|
||||
{
|
||||
pair.mutual=mutual.info(alignset.wt,alignset.ht,alignset.target,alignset.render);
|
||||
pair.imageId=r;
|
||||
pair.projId=p;
|
||||
pair.weight=pair.area*pair.mutual;
|
||||
weightList.push_back(pair);
|
||||
if (pair.area>0.2)
|
||||
{
|
||||
pair.mutual=mutual.info(alignset.wt,alignset.ht,alignset.target,alignset.render);
|
||||
pair.imageId=r;
|
||||
pair.projId=p;
|
||||
pair.weight=pair.area*pair.mutual;
|
||||
weightList.push_back(pair);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
++p;
|
||||
}
|
||||
|
||||
log("Image %d completed",r);
|
||||
@ -625,8 +633,6 @@ std::vector<AlignPair> FilterMutualGlobal::CalcPairs(MeshDocument &md, bool glob
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
std::sort(weightList.begin(), weightList.end(), orderingW());
|
||||
|
||||
///////////////////////////////////////7
|
||||
@ -634,8 +640,8 @@ std::vector<AlignPair> FilterMutualGlobal::CalcPairs(MeshDocument &md, bool glob
|
||||
{
|
||||
int p=weightList[i].projId;
|
||||
alignset.mode=AlignSet::PROJIMG;
|
||||
alignset.shotPro=md.rasterList[p]->shot;
|
||||
alignset.imagePro=&md.rasterList[p]->currentPlane->image;
|
||||
alignset.shotPro=rm->shot;
|
||||
alignset.imagePro=&rm->currentPlane->image;
|
||||
alignset.ProjectedImageChanged(*alignset.imagePro);
|
||||
float countTot=0.0;
|
||||
float countCol=0.0;
|
||||
@ -662,31 +668,32 @@ std::vector<AlignPair> FilterMutualGlobal::CalcPairs(MeshDocument &md, bool glob
|
||||
}
|
||||
}
|
||||
}
|
||||
pair.area=countCol/countTot;
|
||||
/*covered.save("covered.jpg");
|
||||
alignset.rend.save("rend.jpg");
|
||||
alignset.comb.save("comb.jpg");*/
|
||||
pair.area=countCol/countTot;
|
||||
/*covered.save("covered.jpg");
|
||||
alignset.rend.save("rend.jpg");
|
||||
alignset.comb.save("comb.jpg");*/
|
||||
|
||||
pair.area*=countCov/countTot;
|
||||
pair.mutual=mutual.info(alignset.wt,alignset.ht,alignset.target,alignset.render);
|
||||
pair.imageId=r;
|
||||
pair.projId=p;
|
||||
pair.weight=weightList[i].weight;
|
||||
list.push_back(pair);
|
||||
log("Area %3.2f, Mutual %3.2f",pair.area,pair.mutual);
|
||||
}
|
||||
pair.area*=countCov/countTot;
|
||||
pair.mutual=mutual.info(alignset.wt,alignset.ht,alignset.target,alignset.render);
|
||||
pair.imageId=r;
|
||||
pair.projId=p;
|
||||
pair.weight=weightList[i].weight;
|
||||
list.push_back(pair);
|
||||
log("Area %3.2f, Mutual %3.2f",pair.area,pair.mutual);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////
|
||||
++r;
|
||||
}
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
log("Tot arcs %d, Valid arcs %d",(md.rasterList.size())*(md.rasterList.size()-1),list.size());
|
||||
|
||||
|
||||
//emit md.rasterSetChanged();
|
||||
//emit md.rasterSetChanged();
|
||||
//this->glContext->doneCurrent();
|
||||
return list;
|
||||
|
||||
@ -772,6 +779,7 @@ std::vector<SubGraph> FilterMutualGlobal::CreateGraphs(MeshDocument &md, std::ve
|
||||
{
|
||||
SubGraph graph;
|
||||
graph.id=i;
|
||||
auto rmit = md.rasterList.begin();
|
||||
for (int j=0; j<numNodes; j++)
|
||||
{
|
||||
log("Node %d of %d",j,numNodes);
|
||||
@ -779,7 +787,7 @@ std::vector<SubGraph> FilterMutualGlobal::CreateGraphs(MeshDocument &md, std::ve
|
||||
{
|
||||
Node n;
|
||||
double mut=0.0; double are=0.00001;
|
||||
if(md.rasterList[j]->visible)
|
||||
if((*rmit)->visible)
|
||||
n.active=false;
|
||||
else
|
||||
n.active=true;
|
||||
@ -807,6 +815,7 @@ std::vector<SubGraph> FilterMutualGlobal::CreateGraphs(MeshDocument &md, std::ve
|
||||
graph.nodes.push_back(n);
|
||||
log("Node %d of %d: not used",j,numNodes);
|
||||
}
|
||||
++rmit;
|
||||
}
|
||||
Gr.push_back(graph);
|
||||
}
|
||||
@ -898,15 +907,19 @@ bool FilterMutualGlobal::AlignNode(MeshDocument &md, Node node)
|
||||
alignset.mode=AlignSet::NODE;
|
||||
//alignset.node=&node;
|
||||
|
||||
alignset.image=&md.rasterList[node.id]->currentPlane->image;
|
||||
alignset.shot=md.rasterList[node.id]->shot;
|
||||
auto it= md.rasterList.begin(); std::advance(it, node.id);
|
||||
RasterModel* rm = *it;
|
||||
alignset.image=&rm->currentPlane->image;
|
||||
alignset.shot=rm->shot;
|
||||
|
||||
alignset.mesh=&md.mm()->cm;
|
||||
|
||||
for (int l=0; l<node.arcs.size(); l++)
|
||||
{
|
||||
alignset.arcImages.push_back(&md.rasterList[node.arcs[l].projId]->currentPlane->image);
|
||||
alignset.arcShots.push_back(&md.rasterList[node.arcs[l].projId]->shot);
|
||||
auto lit = md.rasterList.begin(); std::advance(lit, node.arcs[l].projId);
|
||||
RasterModel* lrm =*lit;
|
||||
alignset.arcImages.push_back(&lrm->currentPlane->image);
|
||||
alignset.arcShots.push_back(&lrm->shot);
|
||||
alignset.arcMI.push_back(node.arcs[l].mutual);
|
||||
|
||||
}
|
||||
@ -915,17 +928,21 @@ bool FilterMutualGlobal::AlignNode(MeshDocument &md, Node node)
|
||||
return true;
|
||||
else if(alignset.arcImages.size()==1)
|
||||
{
|
||||
alignset.arcImages.push_back(&md.rasterList[node.arcs[0].projId]->currentPlane->image);
|
||||
alignset.arcShots.push_back(&md.rasterList[node.arcs[0].projId]->shot);
|
||||
auto lit = md.rasterList.begin(); std::advance(lit, node.arcs[0].projId);
|
||||
RasterModel* lrm =*lit;
|
||||
alignset.arcImages.push_back(&lrm->currentPlane->image);
|
||||
alignset.arcShots.push_back(&lrm->shot);
|
||||
alignset.arcMI.push_back(node.arcs[0].mutual);
|
||||
alignset.arcImages.push_back(&md.rasterList[node.arcs[0].projId]->currentPlane->image);
|
||||
alignset.arcShots.push_back(&md.rasterList[node.arcs[0].projId]->shot);
|
||||
alignset.arcImages.push_back(&lrm->currentPlane->image);
|
||||
alignset.arcShots.push_back(&lrm->shot);
|
||||
alignset.arcMI.push_back(node.arcs[0].mutual);
|
||||
}
|
||||
else if(alignset.arcImages.size()==2)
|
||||
{
|
||||
alignset.arcImages.push_back(&md.rasterList[node.arcs[0].projId]->currentPlane->image);
|
||||
alignset.arcShots.push_back(&md.rasterList[node.arcs[0].projId]->shot);
|
||||
auto lit = md.rasterList.begin(); std::advance(lit, node.arcs[0].projId);
|
||||
RasterModel* lrm =*lit;
|
||||
alignset.arcImages.push_back(&lrm->currentPlane->image);
|
||||
alignset.arcShots.push_back(&lrm->shot);
|
||||
alignset.arcMI.push_back(node.arcs[0].mutual);
|
||||
}
|
||||
|
||||
@ -944,14 +961,14 @@ bool FilterMutualGlobal::AlignNode(MeshDocument &md, Node node)
|
||||
unsigned int *indices = new unsigned int[alignset.mesh->fn*3];
|
||||
|
||||
for(int i = 0; i < alignset.mesh->vn; i++) {
|
||||
vertices[i] = alignset.mesh->vert[i].P();
|
||||
normals[i] = alignset.mesh->vert[i].N();
|
||||
colors[i] = alignset.mesh->vert[i].C();
|
||||
vertices[i] = alignset.mesh->vert[i].P();
|
||||
normals[i] = alignset.mesh->vert[i].N();
|
||||
colors[i] = alignset.mesh->vert[i].C();
|
||||
}
|
||||
|
||||
for(int i = 0; i < alignset.mesh->fn; i++)
|
||||
for(int k = 0; k < 3; k++)
|
||||
indices[k+i*3] = alignset.mesh->face[i].V(k) - &*alignset.mesh->vert.begin();
|
||||
for(int k = 0; k < 3; k++)
|
||||
indices[k+i*3] = alignset.mesh->face[i].V(k) - &*alignset.mesh->vert.begin();
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.vbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Point3f),
|
||||
@ -991,14 +1008,14 @@ bool FilterMutualGlobal::AlignNode(MeshDocument &md, Node node)
|
||||
|
||||
|
||||
//md.rasterList[node.id]->shot=alignset.shot;
|
||||
md.rasterList[node.id]->shot=alignset.shot;
|
||||
float ratio=(float)md.rasterList[node.id]->currentPlane->image.height()/(float)alignset.shot.Intrinsics.ViewportPx[1];
|
||||
md.rasterList[node.id]->shot.Intrinsics.ViewportPx[0]=md.rasterList[node.id]->currentPlane->image.width();
|
||||
md.rasterList[node.id]->shot.Intrinsics.ViewportPx[1]=md.rasterList[node.id]->currentPlane->image.height();
|
||||
md.rasterList[node.id]->shot.Intrinsics.PixelSizeMm[1]/=ratio;
|
||||
md.rasterList[node.id]->shot.Intrinsics.PixelSizeMm[0]/=ratio;
|
||||
md.rasterList[node.id]->shot.Intrinsics.CenterPx[0]=(int)((float)md.rasterList[node.id]->shot.Intrinsics.ViewportPx[0]/2.0);
|
||||
md.rasterList[node.id]->shot.Intrinsics.CenterPx[1]=(int)((float)md.rasterList[node.id]->shot.Intrinsics.ViewportPx[1]/2.0);
|
||||
rm->shot=alignset.shot;
|
||||
float ratio=(float)rm->currentPlane->image.height()/(float)alignset.shot.Intrinsics.ViewportPx[1];
|
||||
rm->shot.Intrinsics.ViewportPx[0]=rm->currentPlane->image.width();
|
||||
rm->shot.Intrinsics.ViewportPx[1]=rm->currentPlane->image.height();
|
||||
rm->shot.Intrinsics.PixelSizeMm[1]/=ratio;
|
||||
rm->shot.Intrinsics.PixelSizeMm[0]/=ratio;
|
||||
rm->shot.Intrinsics.CenterPx[0]=(int)((float)rm->shot.Intrinsics.ViewportPx[0]/2.0);
|
||||
rm->shot.Intrinsics.CenterPx[1]=(int)((float)rm->shot.Intrinsics.ViewportPx[1]/2.0);
|
||||
//this->glContext->doneCurrent();
|
||||
//emit md.rasterSetChanged();
|
||||
for (int l=0; l<alignset.arcImages.size(); l++)
|
||||
@ -1028,14 +1045,14 @@ bool FilterMutualGlobal::UpdateGraph(MeshDocument &md, SubGraph graph, int n)
|
||||
unsigned int *indices = new unsigned int[alignset.mesh->fn*3];
|
||||
|
||||
for(int i = 0; i < alignset.mesh->vn; i++) {
|
||||
vertices[i] = alignset.mesh->vert[i].P();
|
||||
normals[i] = alignset.mesh->vert[i].N();
|
||||
colors[i] = alignset.mesh->vert[i].C();
|
||||
vertices[i] = alignset.mesh->vert[i].P();
|
||||
normals[i] = alignset.mesh->vert[i].N();
|
||||
colors[i] = alignset.mesh->vert[i].C();
|
||||
}
|
||||
|
||||
for(int i = 0; i < alignset.mesh->fn; i++)
|
||||
for(int k = 0; k < 3; k++)
|
||||
indices[k+i*3] = alignset.mesh->face[i].V(k) - &*alignset.mesh->vert.begin();
|
||||
for(int k = 0; k < 3; k++)
|
||||
indices[k+i*3] = alignset.mesh->face[i].V(k) - &*alignset.mesh->vert.begin();
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, alignset.vbo);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, alignset.mesh->vn*sizeof(vcg::Point3f),
|
||||
@ -1068,11 +1085,12 @@ bool FilterMutualGlobal::UpdateGraph(MeshDocument &md, SubGraph graph, int n)
|
||||
//////////////////
|
||||
int imageId=graph.nodes[h].arcs[l].imageId;
|
||||
int imageProj=graph.nodes[h].arcs[l].projId;
|
||||
|
||||
auto it= md.rasterList.begin(); std::advance(it, imageId);
|
||||
RasterModel* rm = *it;
|
||||
//this->glContext->makeCurrent();
|
||||
|
||||
alignset.image=&md.rasterList[imageId]->currentPlane->image;
|
||||
alignset.shot=md.rasterList[imageId]->shot;
|
||||
alignset.image=&rm->currentPlane->image;
|
||||
alignset.shot=rm->shot;
|
||||
|
||||
//this->initGL();
|
||||
alignset.resize(800);
|
||||
@ -1089,8 +1107,8 @@ bool FilterMutualGlobal::UpdateGraph(MeshDocument &md, SubGraph graph, int n)
|
||||
alignset.comb=alignset.rend;*/
|
||||
|
||||
alignset.mode=AlignSet::PROJIMG;
|
||||
alignset.shotPro=md.rasterList[imageProj]->shot;
|
||||
alignset.imagePro=&md.rasterList[imageProj]->currentPlane->image;
|
||||
alignset.shotPro=rm->shot;
|
||||
alignset.imagePro=&rm->currentPlane->image;
|
||||
alignset.ProjectedImageChanged(*alignset.imagePro);
|
||||
float countTot=0.0;
|
||||
float countCol=0.0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user