Commit b086df81 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of icube-forge.unistra.fr:cgogn/cgogn into develop

parents 80fef77f 2205b655
......@@ -64,7 +64,7 @@ public:
* the management of holes is shared by all attributes
*/
class CGoGN_CONTAINER_API AttributeContainer
class CGoGN_CONTAINER_API AttributeContainer
{
public:
/**
......@@ -156,7 +156,7 @@ public:
void setRegistry(std::map<std::string, RegisteredBaseAttribute*>* re);
void setContainerBrowser(ContainerBrowser* bro) { m_currentBrowser = bro;}
void setContainerBrowser(ContainerBrowser* bro) { m_currentBrowser = bro; }
bool hasBrowser() { return m_currentBrowser != NULL; }
......@@ -176,7 +176,6 @@ public:
/// special version for marker
AttributeMultiVector<MarkerBool>* addMarkerAttribute(const std::string& attribName);
/**
* add a new attribute to the container
* @param typeName type of the new attribute in a string
......@@ -185,7 +184,6 @@ public:
*/
AttributeMultiVectorGen* addAttribute(const std::string& typeName, const std::string& attribName);
protected:
/**
* add a new attribute with a given index (for load only)
......@@ -275,8 +273,6 @@ public:
*/
void next(unsigned int &it) const;
/**
* return the index of the first line of the container
*/
......@@ -293,7 +289,6 @@ public:
*/
void realNext(unsigned int &it) const;
/**
* return the index of the last line of the container
*/
......@@ -334,7 +329,7 @@ public:
* @return number of blocks
*/
template<typename T>
unsigned int getAttributeBlocksPointers(unsigned int attrIndex, std::vector<T*>& vect_ptr, unsigned int& byteBlockSize);
unsigned int getAttributeBlocksPointers(unsigned int attrIndex, std::vector<T*>& vect_ptr, unsigned int& byteBlockSize) const;
/**
* fill a vector with attributes names
......@@ -343,13 +338,12 @@ public:
*/
unsigned int getAttributesNames(std::vector<std::string>& names) const;
/**
* fill a vector with attribute type names
* @param types vector of type names
* @return number of attributes
*/
unsigned int getAttributesTypes(std::vector<std::string>& types);
unsigned int getAttributesTypes(std::vector<std::string>& types) const;
std::vector<AttributeMultiVector<MarkerBool>*>& getMarkerAttributes();
......@@ -468,7 +462,6 @@ public:
inline AttributeMultiVectorGen* getVirtualDataVector(unsigned int attrIndex);
/**
* get an AttributeMultiVector
* @param attribName name of the attribute
......@@ -508,8 +501,6 @@ public:
template <typename T>
void setData(unsigned int attrIndex, unsigned int eltIndex, const T& data);
/**************************************
* SAVE & LOAD *
**************************************/
......@@ -548,19 +539,14 @@ public:
void dumpCSV() const;
void dumpByLines() const;
};
} // namespace CGoGN
#include "attributeContainer.hpp"
#include "Container/attributeContainer.hpp"
#endif
///**
//* Container for AttributeMultiVectors
//* All the attributes always have the same size and
......
......@@ -198,7 +198,7 @@ bool AttributeContainer::removeAttribute(unsigned int index)
}
template <typename T>
unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrIndex, std::vector<T*>& vect_ptr, unsigned int& byteBlockSize)
unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrIndex, std::vector<T*>& vect_ptr, unsigned int& byteBlockSize) const
{
assert(attrIndex < m_tableAttribs.size() || !"getAttributeBlocksPointers: attribute index out of bounds");
assert(m_tableAttribs[attrIndex] != NULL || !"getAttributeBlocksPointers: attribute does not exist");
......@@ -208,7 +208,6 @@ unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrInd
return atm->getBlocksPointers(vect_ptr, byteBlockSize);
}
/**************************************
* INFO ABOUT THE CONTAINER *
**************************************/
......@@ -316,7 +315,6 @@ inline void AttributeContainer::realNext(unsigned int &it) const
} while ((it < m_maxSize) && (!used(it)));
}
inline unsigned int AttributeContainer::realRBegin() const
{
unsigned int it = m_maxSize-1;
......@@ -338,9 +336,6 @@ inline void AttributeContainer::realRNext(unsigned int &it) const
} while ((it !=0xffffffff) && (!used(it)));
}
/**************************************
* LINES MANAGEMENT *
**************************************/
......@@ -362,7 +357,6 @@ inline void AttributeContainer::initMarkersOfLine(unsigned int index)
}
}
inline void AttributeContainer::copyLine(unsigned int dstIndex, unsigned int srcIndex)
{
for(unsigned int i = 0; i < m_tableAttribs.size(); ++i)
......@@ -375,7 +369,6 @@ inline void AttributeContainer::copyLine(unsigned int dstIndex, unsigned int src
{
m_tableMarkerAttribs[i]->copyElt(dstIndex, srcIndex);
}
}
inline void AttributeContainer::refLine(unsigned int index)
......@@ -452,7 +445,6 @@ AttributeMultiVector<T>* AttributeContainer::getDataVector(const std::string& at
return atm;
}
inline CGoGNCodeType AttributeContainer::getTypeCode(const std::string& attribName) const
{
unsigned int index = getAttributeIndex(attribName) ;
......@@ -461,8 +453,6 @@ inline CGoGNCodeType AttributeContainer::getTypeCode(const std::string& attribNa
return m_tableAttribs[index]->getTypeCode();
}
inline AttributeMultiVectorGen* AttributeContainer::getVirtualDataVector(const std::string& attribName)
{
unsigned int index = getAttributeIndex(attribName) ;
......@@ -511,12 +501,9 @@ inline void AttributeContainer::setData(unsigned int attrIndex, unsigned int elt
atm->operator[](eltIndex) = data;
}
inline std::vector<AttributeMultiVector<MarkerBool>*>& AttributeContainer::getMarkerAttributes()
{
return m_tableMarkerAttribs;
}
} // namespace CGoGN
......@@ -81,7 +81,6 @@ template <typename VEC>
typename VEC::DATA_TYPE BoundingBox<VEC>::maxSize() const
{
assert(m_initialized || !"Bounding box not initialized");
typename VEC::DATA_TYPE max = m_pMax[0] - m_pMin[0] ;
for(unsigned int i = 1; i < m_pMax.dimension(); ++i)
{
......@@ -96,7 +95,6 @@ template <typename VEC>
typename VEC::DATA_TYPE BoundingBox<VEC>::minSize() const
{
assert(m_initialized || !"Bounding box not initialized");
typename VEC::DATA_TYPE min = m_pMax[0] - m_pMin[0] ;
for(unsigned int i = 1; i < m_pMax.dimension(); ++i)
{
......@@ -143,6 +141,8 @@ template <typename VEC>
void BoundingBox<VEC>::reset()
{
m_initialized = false;
m_pMin = VEC(0);
m_pMax = VEC(0);
}
template <typename VEC>
......
......@@ -47,7 +47,6 @@
#include "Topology/dll.h"
namespace CGoGN
{
......
......@@ -92,7 +92,6 @@ namespace CGoGN
return m_tableAttribs[index]->getName() ;
}
unsigned int AttributeContainer::getAttributesNames(std::vector<std::string>& names) const
{
names.clear() ;
......@@ -107,23 +106,20 @@ namespace CGoGN
return m_nbAttributes ;
}
unsigned int AttributeContainer::getAttributesTypes(std::vector<std::string>& types)
unsigned int AttributeContainer::getAttributesTypes(std::vector<std::string>& types) const
{
types.clear() ;
types.reserve(m_nbAttributes) ;
for (unsigned int i = 0; i < m_tableAttribs.size(); ++i)
{
if(m_tableAttribs[i] != NULL)
if (m_tableAttribs[i] != NULL)
types.push_back(m_tableAttribs[i]->getTypeName()) ;
}
return m_nbAttributes ;
}
/**************************************
* CONTAINER MANAGEMENT *
**************************************/
......
......@@ -5,6 +5,8 @@
#include "Algo/Topo/basic.h"
#include "camera.h"
#include <QKeyEvent>
#include <QMouseEvent>
......@@ -35,25 +37,25 @@ void MapParameters::start(MapHandlerGen* mhg)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
positionInit = mh->getAttribute<PFP2::VEC3, VERTEX>("positionInit", false);
positionInit = mh->getAttribute<PFP2::VEC3, VERTEX>("positionInit");
if(!positionInit.isValid())
positionInit = mh->addAttribute<PFP2::VEC3, VERTEX>("positionInit", false);
positionInit = mh->addAttribute<PFP2::VEC3, VERTEX>("positionInit");
diffCoord = mh->getAttribute<PFP2::VEC3, VERTEX>("diffCoord", false);
diffCoord = mh->getAttribute<PFP2::VEC3, VERTEX>("diffCoord");
if(!diffCoord.isValid())
diffCoord = mh->addAttribute<PFP2::VEC3, VERTEX>("diffCoord", false);
diffCoord = mh->addAttribute<PFP2::VEC3, VERTEX>("diffCoord");
vertexRotationMatrix = mh->getAttribute<Eigen_Matrix3f, VERTEX>("vertexRotationMatrix", false);
vertexRotationMatrix = mh->getAttribute<Eigen_Matrix3f, VERTEX>("vertexRotationMatrix");
if(!vertexRotationMatrix.isValid())
vertexRotationMatrix = mh->addAttribute<Eigen_Matrix3f, VERTEX>("vertexRotationMatrix", false);
vertexRotationMatrix = mh->addAttribute<Eigen_Matrix3f, VERTEX>("vertexRotationMatrix");
rotatedDiffCoord = mh->getAttribute<PFP2::VEC3, VERTEX>("rotatedDiffCoord", false);
rotatedDiffCoord = mh->getAttribute<PFP2::VEC3, VERTEX>("rotatedDiffCoord");
if(!rotatedDiffCoord.isValid())
rotatedDiffCoord = mh->addAttribute<PFP2::VEC3, VERTEX>("rotatedDiffCoord", false);
rotatedDiffCoord = mh->addAttribute<PFP2::VEC3, VERTEX>("rotatedDiffCoord");
vIndex = mh->getAttribute<unsigned int, VERTEX>("vIndex", false);
vIndex = mh->getAttribute<unsigned int, VERTEX>("vIndex");
if(!vIndex.isValid())
vIndex = mh->addAttribute<unsigned int, VERTEX>("vIndex", false);
vIndex = mh->addAttribute<unsigned int, VERTEX>("vIndex");
PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(mh)->getMap();
......@@ -153,6 +155,7 @@ void Surface_Deformation_Plugin::keyPress(View* view, QKeyEvent* event)
m_dragging = true;
m_draginit = false;
view->setMouseTracking(true);
view->getCurrentCamera()->disableViewsBoundingBoxFitting();
}
}
else
......@@ -160,6 +163,7 @@ void Surface_Deformation_Plugin::keyPress(View* view, QKeyEvent* event)
m_dragging = false;
m_draginit = false;
view->setMouseTracking(false);
view->getCurrentCamera()->enableViewsBoundingBoxFitting();
}
}
break;
......@@ -174,7 +178,6 @@ void Surface_Deformation_Plugin::keyPress(View* view, QKeyEvent* event)
{
asRigidAsPossible(mh);
mh->notifyAttributeModification(p.positionAttribute);
static_cast<MapHandler<PFP2>*>(mh)->updateBB(p.positionAttribute);
view->updateGL();
}
}
......@@ -185,17 +188,17 @@ void Surface_Deformation_Plugin::keyPress(View* view, QKeyEvent* event)
void Surface_Deformation_Plugin::mouseMove(View* view, QMouseEvent* event)
{
if(m_dragging)
if (m_dragging)
{
MapHandlerGen* mh = m_schnapps->getSelectedMap();
MapParameters& p = h_parameterSet[mh];
const std::vector<Vertex>& handle = p.handleSelector->getSelectedCells();
if(!m_draginit)
if (!m_draginit)
{
m_dragZ = 0;
for(std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
for (std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
{
const PFP2::VEC3& pp = p.positionAttribute[*it];
qglviewer::Vec q = view->camera()->projectedCoordinatesOf(qglviewer::Vec(pp[0],pp[1],pp[2]));
......@@ -215,17 +218,16 @@ void Surface_Deformation_Plugin::mouseMove(View* view, QMouseEvent* event)
qglviewer::Vec vec = qq - m_dragPrevious;
PFP2::VEC3 t(vec.x, vec.y, vec.z);
for(std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
for (std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
p.positionAttribute[*it] += t;
m_dragPrevious = qq;
// matchDiffCoord(map);
if(p.initialized)
if (p.initialized)
{
asRigidAsPossible(mh);
mh->notifyAttributeModification(p.positionAttribute);
static_cast<MapHandler<PFP2>*>(mh)->updateBB(p.positionAttribute);
}
}
......
......@@ -38,7 +38,7 @@ private slots:
void computeNormalFromDialog();
void computeCurvatureFromDialog();
void appsFinished();
void schnappsClosing();
public slots:
void computeNormal(const QString& mapName,
......
......@@ -37,7 +37,7 @@ bool Surface_DifferentialProperties_Plugin::enable()
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
connect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(schnappsClosing()));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
......@@ -60,7 +60,7 @@ void Surface_DifferentialProperties_Plugin::disable()
disconnect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
disconnect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(schnappsClosing()));
}
void Surface_DifferentialProperties_Plugin::mapAdded(MapHandlerGen *map)
......@@ -309,7 +309,7 @@ void Surface_DifferentialProperties_Plugin::computeCurvature(
}
}
void Surface_DifferentialProperties_Plugin::appsFinished()
void Surface_DifferentialProperties_Plugin::schnappsClosing()
{
m_computeNormalDialog->close();
m_computeCurvatureDialog->close();
......
......@@ -30,7 +30,7 @@ private slots:
void openComputeDistanceDialog();
void computeDistanceFromDialog();
void appsFinished();
void schnappsClosing();
public slots:
void computeDistance(
......
......@@ -28,8 +28,8 @@ Dialog_ComputeDistance::Dialog_ComputeDistance(SCHNApps* s) :
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
{
QListWidgetItem* item1 = new QListWidgetItem(map->getName(), list_maps_1);
QListWidgetItem* item2 = new QListWidgetItem(map->getName(), list_maps_2);
list_maps_1->addItem(map->getName());
list_maps_2->addItem(map->getName());
}
}
......@@ -109,8 +109,8 @@ void Dialog_ComputeDistance::selectedMap2Changed()
void Dialog_ComputeDistance::addMapToList(MapHandlerGen* map)
{
QListWidgetItem* item1 = new QListWidgetItem(map->getName(), list_maps_1);
QListWidgetItem* item2 = new QListWidgetItem(map->getName(), list_maps_2);
list_maps_1->addItem(map->getName());
list_maps_2->addItem(map->getName());
}
void Dialog_ComputeDistance::removeMapFromList(MapHandlerGen* map)
......
......@@ -26,7 +26,7 @@ bool Surface_Distance_Plugin::enable()
connect(m_computeDistanceDialog, SIGNAL(accepted()), this, SLOT(computeDistanceFromDialog()));
connect(m_computeDistanceDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeDistanceFromDialog()));
connect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
connect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(schnappsClosing()));
return true;
}
......@@ -38,7 +38,7 @@ void Surface_Distance_Plugin::disable()
disconnect(m_computeDistanceDialog, SIGNAL(accepted()), this, SLOT(computeDistanceFromDialog()));
disconnect(m_computeDistanceDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeDistanceFromDialog()));
disconnect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
disconnect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(schnappsClosing()));
}
void Surface_Distance_Plugin::openComputeDistanceDialog()
......@@ -133,7 +133,7 @@ void Surface_Distance_Plugin::computeDistance(
mh2->notifyAttributeModification(distance2);
}
void Surface_Distance_Plugin::appsFinished()
void Surface_Distance_Plugin::schnappsClosing()
{
m_computeDistanceDialog->close();
}
......
......@@ -39,15 +39,16 @@ MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName)
std::vector<std::string> attrNames;
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toStdString(), attrNames);
// get vertex position attribute
VertexAttribute<PFP2::VEC3, PFP2::MAP> position = map->getAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>(attrNames[0]);
mh->registerAttribute(position);
// update corresponding VBO & emit attribute update signal
mh->notifyAttributeModification(position);
// compute map bounding box
mh->updateBB(position);
for (unsigned int orbit = VERTEX; orbit <= VOLUME; orbit++)
{
AttributeContainer& cont = map->getAttributeContainer(orbit);
std::vector<std::string> names;
std::vector<std::string> types;
cont.getAttributesNames(names);
cont.getAttributesTypes(types);
for(unsigned int i = 0; i < names.size(); ++i)
mhg->registerAttribute(orbit, QString::fromStdString(names[i]), QString::fromStdString(types[i]));
}
}
return mhg;
}
......
......@@ -251,8 +251,7 @@ void Surface_Modelisation_Plugin::createNewFace(MapHandlerGen* mhg)
}
mh->notifyConnectivityModification();
mh->notifyAttributeModification(position);
mh->updateBB(position);
mh->notifyAttributeModification(position);
collectedVertices.clear();
}
else QMessageBox::information(0, "Attention", "To create a face you need at least 3 vertices");
......@@ -271,9 +270,7 @@ void Surface_Modelisation_Plugin::addCube(MapHandlerGen *mhg)
Algo::Surface::Modelisation::embedPrism<PFP2>(*map, position, 4, true, 0.7f, 0.7f, 1.0f);
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
// compute map bounding box
mh->updateBB(position);
mh->notifyConnectivityModification();
}
}
......@@ -417,8 +414,7 @@ void Surface_Modelisation_Plugin::extrudeRegion(MapHandlerGen *mhg)
Algo::Surface::Modelisation::extrudeRegion<PFP2>(*map, p.positionAttribute, selectedDarts[0], p.faceSelector->getMarker());
mh->notifyConnectivityModification();
mh->notifyAttributeModification(p.positionAttribute);
mh->updateBB(p.positionAttribute);
mh->notifyAttributeModification(p.positionAttribute);
}
}
......@@ -739,8 +735,7 @@ void Surface_Modelisation_Plugin::extrudeFace(MapHandlerGen *mhg)
Algo::Surface::Modelisation::extrudeFace<PFP2>(*map, p.positionAttribute, d, dist);
mh->notifyConnectivityModification();
mh->notifyAttributeModification(p.positionAttribute);
mh->updateBB(p.positionAttribute);
mh->notifyAttributeModification(p.positionAttribute);
}
}
......@@ -790,13 +785,11 @@ void Surface_Modelisation_Plugin::pathExtrudeFace(MapHandlerGen *mhg)
}
mh->notifyConnectivityModification();
mh->notifyAttributeModification(position);
mh->updateBB(position);
mh->notifyAttributeModification(position);
collectedVertices.clear();
}
}
Q_EXPORT_PLUGIN2(Surface_Modelisation_Plugin, Surface_Modelisation_Plugin)
} // namespace SCHNApps
......
......@@ -216,14 +216,9 @@ MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName)
// get vertex position attribute
VertexAttribute<PFP2::VEC3, PFP2::MAP> position = map->getAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("position") ;
VertexAttribute<PFP2::VEC3, PFP2::MAP> normal = map->getAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("normal");
mh->registerAttribute(position);
mh->registerAttribute(normal);
// update corresponding VBO & emit attribute update signal
mh->notifyAttributeModification(position);
mh->notifyAttributeModification(normal);
MapParameters& mapParams = h_mapParameterSet[mhg];
mapParams.nbVertices = Algo::Topo::getNbOrbits<VERTEX>(*map);
......@@ -271,9 +266,6 @@ MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName)
mapParams.radiancePerVertexShader = new Utils::ShaderRadiancePerVertex(Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_resolution());
registerShader(mapParams.radiancePerVertexShader);
// compute map bounding box
mh->updateBB(position);
}
return mhg;
}
......
......@@ -25,6 +25,18 @@
</item>
<item>
<widget class="QPushButton" name="scolorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>Color</string>
</property>
......@@ -146,6 +158,18 @@
</item>
<item>
<widget class="QPushButton" name="dcolorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="palette">
<palette>
<active>
......@@ -282,6 +306,18 @@
</item>
<item>
<widget class="QPushButton" name="vcolorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>