Commit c8558691 authored by Lionel Untereiner's avatar Lionel Untereiner

some changes

parent 38233cd7
...@@ -170,7 +170,8 @@ void MCMesh::updateRender() ...@@ -170,7 +170,8 @@ void MCMesh::updateRender()
void MCMesh::fromFile(char* fname) void MCMesh::fromFile(char* fname)
{ {
myImg = new SAlgo::MC::Image<DATATYPE>(); myImg = new SAlgo::MC::Image<DATATYPE>();
myImg->loadInrgz(fname); //myImg->loadInrgz(fname);
myImg->loadVox(fname);
CGoGNout << "Image chargee"<<CGoGNendl; CGoGNout << "Image chargee"<<CGoGNendl;
CGoGNout << myImg->getWidthX() <<"x"<< myImg->getWidthY() <<"x"<< myImg->getWidthZ() << "voxels"<<CGoGNendl; CGoGNout << myImg->getWidthX() <<"x"<< myImg->getWidthY() <<"x"<< myImg->getWidthZ() << "voxels"<<CGoGNendl;
} }
......
...@@ -157,6 +157,17 @@ void MyQT::operation(int x) ...@@ -157,6 +157,17 @@ void MyQT::operation(int x)
m_selected2=NIL; m_selected2=NIL;
} }
break; break;
case 10:
CGoGNout <<"split surface"<<CGoGNendl;
if (!m_selecteds.empty())
{
myMap.splitSurface(m_selecteds);
updateMap();
m_selected=NIL;
m_selected2=NIL;
m_selecteds.clear();
}
break;
default: default:
break; break;
...@@ -256,6 +267,12 @@ void MyQT::cb_redraw() ...@@ -256,6 +267,12 @@ void MyQT::cb_redraw()
if (m_selected2 != NIL) if (m_selected2 != NIL)
m_render_topo->overdrawDart(m_selected2, 11, 0.0f, 1.0f, 0.0f); m_render_topo->overdrawDart(m_selected2, 11, 0.0f, 1.0f, 0.0f);
if(!m_selecteds.empty())
{
for(std::vector<Dart>::iterator it = m_selecteds.begin() ; it != m_selecteds.end() ; ++it)
m_render_topo->overdrawDart(*it, 11, 0.0f, 0.0f, 1.0f);
}
} }
void MyQT::cb_mousePress(int button, int x, int y) void MyQT::cb_mousePress(int button, int x, int y)
...@@ -275,6 +292,17 @@ void MyQT::cb_mousePress(int button, int x, int y) ...@@ -275,6 +292,17 @@ void MyQT::cb_mousePress(int button, int x, int y)
} }
updateGL(); updateGL();
} }
if(Control())
{
Dart d = m_render_topo->picking(myMap, x,y); // nb
if (button == Qt::LeftButton)
{
if (d == Dart::nil())
m_selecteds.clear();
else
m_selecteds.push_back(d);
}
}
} }
void MyQT::cb_keyPress(int keycode) void MyQT::cb_keyPress(int keycode)
......
...@@ -94,6 +94,7 @@ protected: ...@@ -94,6 +94,7 @@ protected:
#endif #endif
Dart m_selected; Dart m_selected;
Dart m_selected2; Dart m_selected2;
std::vector<Dart> m_selecteds;
DartMarker<MAP> dm; DartMarker<MAP> dm;
float m_shift; float m_shift;
......
...@@ -36,7 +36,16 @@ ...@@ -36,7 +36,16 @@
</size> </size>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin"> <property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number> <number>2</number>
</property> </property>
<property name="spacing"> <property name="spacing">
...@@ -99,6 +108,11 @@ ...@@ -99,6 +108,11 @@
<string>deleteFace</string> <string>deleteFace</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>splitSurface</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item> <item>
......
...@@ -248,6 +248,24 @@ void MyQT::operation(int x) ...@@ -248,6 +248,24 @@ void MyQT::operation(int x)
updateMap(); updateMap();
} }
break; break;
case 13 :
CGoGNout <<"split volume"<<CGoGNendl;
if (!m_selecteds.empty())
{
myMap.splitVolume(m_selecteds);
m_selecteds.clear();
updateMap();
}
break;
case 14 :
CGoGNout <<"cut volume"<<CGoGNendl;
if (!m_selecteds.empty())
{
myMap.cutVolume(m_selecteds);
m_selecteds.clear();
updateMap();
}
break;
default: default:
break; break;
} }
...@@ -470,12 +488,12 @@ void MyQT::cb_mousePress(int button, int x, int y) ...@@ -470,12 +488,12 @@ void MyQT::cb_mousePress(int button, int x, int y)
{ {
if (button == Qt::LeftButton) if (button == Qt::LeftButton)
{ {
Dart d = m_render_topo_boundary->picking(myMap, x,y,true); m_selecteds.push_back(Dart(173));
if (d != Dart::nil()) m_selecteds.push_back(Dart(186));
{ m_selecteds.push_back(Dart(185));
Dart e = myMap.phi2(d); m_selecteds.push_back(Dart(171));
std::cout << "Dart "<< d.index << " / phi2:" << e.index << std::endl; m_selecteds.push_back(Dart(170));
} m_selecteds.push_back(Dart(174));
} }
if (button == Qt::RightButton) if (button == Qt::RightButton)
{ {
...@@ -483,8 +501,6 @@ void MyQT::cb_mousePress(int button, int x, int y) ...@@ -483,8 +501,6 @@ void MyQT::cb_mousePress(int button, int x, int y)
if (d != Dart::nil()) if (d != Dart::nil())
{ {
m_selecteds.push_back(d); m_selecteds.push_back(d);
Dart e = myMap.phi2(d);
std::cout << "Dart "<< d.index << " / phi2:" << e.index << std::endl;
} }
} }
......
...@@ -155,6 +155,16 @@ ...@@ -155,6 +155,16 @@
<string>deleteVolume</string> <string>deleteVolume</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>splitVolume</string>
</property>
</item>
<item>
<property name="text">
<string>cutVolume</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
......
...@@ -14,3 +14,5 @@ ADD_SUBDIRECTORY(surface_modelisation) ...@@ -14,3 +14,5 @@ ADD_SUBDIRECTORY(surface_modelisation)
ADD_SUBDIRECTORY(volume_import) ADD_SUBDIRECTORY(volume_import)
#ADD_SUBDIRECTORY(volume_render) #ADD_SUBDIRECTORY(volume_render)
ADD_SUBDIRECTORY(volumetric)
#ifndef _TEXTURE_H_ #ifndef _TEXTURE_H_
#define _TEXTURE_H_ #define _TEXTURE_H_
#include "Utils/gl_def.h"
#include <QSize>
namespace CGoGN namespace CGoGN
{ {
......
...@@ -39,6 +39,7 @@ class Camera; ...@@ -39,6 +39,7 @@ class Camera;
class MapHandlerGen; class MapHandlerGen;
class CellSelectorGen; class CellSelectorGen;
struct Texture; struct Texture;
class ObjectHandlerGen;
typedef QMap<QString, Plugin*> PluginSet; typedef QMap<QString, Plugin*> PluginSet;
typedef QMap<QString, View*> ViewSet; typedef QMap<QString, View*> ViewSet;
...@@ -51,6 +52,8 @@ typedef QMap<QString, Utils::GLSLShader*> ShaderSet; ...@@ -51,6 +52,8 @@ typedef QMap<QString, Utils::GLSLShader*> ShaderSet;
typedef QMap<QString, Texture*> TextureSet; typedef QMap<QString, Texture*> TextureSet;
typedef QMap<QString, ObjectHandlerGen*> ObjectSet;
} // namespace SCHNApps } // namespace SCHNApps
} // namespace CGoGN } // namespace CGoGN
......
...@@ -78,12 +78,7 @@ IF(WIN32) ...@@ -78,12 +78,7 @@ IF(WIN32)
ELSE(WIN32) ELSE(WIN32)
find_package(SuiteSparse REQUIRED) find_package(SuiteSparse REQUIRED)
SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${SUITESPARSE_INCLUDE_DIRS}) SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${SUITESPARSE_INCLUDE_DIRS})
<<<<<<< HEAD
SET (COMMON_LIBS ${SUITESPARSE_LIBRARIES} lapack blas ${COMMON_LIBS}) SET (COMMON_LIBS ${SUITESPARSE_LIBRARIES} lapack blas ${COMMON_LIBS})
=======
SET (COMMON_LIBS ${SUITESPARSE_LIBRARIES} lapack blas ${COMMON_LIBS} )
>>>>>>> c2fbbbce446c3f437c531debda00b48f13f29790
ENDIF(WIN32) ENDIF(WIN32)
#optionnal libs #optionnal libs
......
...@@ -195,12 +195,12 @@ public: ...@@ -195,12 +195,12 @@ public:
/** /**
* Load a raw image * Load a raw image
*/ */
void loadRaw(char *filename); void loadRaw(const char *filename);
/** /**
* Load a vox file * Load a vox file
*/ */
void loadVox(char *filename); void loadVox(const char *filename);
/** /**
* save current image into file * save current image into file
......
...@@ -115,7 +115,7 @@ void Image<DataType>::createMask(const Image<DataTypeIn>& img ) ...@@ -115,7 +115,7 @@ void Image<DataType>::createMask(const Image<DataTypeIn>& img )
template< typename DataType > template< typename DataType >
void Image<DataType>::loadRaw(char *filename) void Image<DataType>::loadRaw(const char *filename)
{ {
std::ifstream fp( filename, std::ios::in|std::ios::binary); std::ifstream fp( filename, std::ios::in|std::ios::binary);
if (!fp.good()) if (!fp.good())
...@@ -147,7 +147,7 @@ void Image<DataType>::loadRaw(char *filename) ...@@ -147,7 +147,7 @@ void Image<DataType>::loadRaw(char *filename)
template< typename DataType > template< typename DataType >
void Image<DataType>::loadVox(char *filename) void Image<DataType>::loadVox(const char *filename)
{ {
std::ifstream in(filename); std::ifstream in(filename);
if (!in) if (!in)
......
...@@ -312,14 +312,14 @@ void IHM2<PFP>::subdivideEdge(Dart d) ...@@ -312,14 +312,14 @@ void IHM2<PFP>::subdivideEdge(Dart d)
unsigned int cur = m_map.getCurrentLevel() ; unsigned int cur = m_map.getCurrentLevel() ;
m_map.setCurrentLevel(eLevel) ; m_map.setCurrentLevel(eLevel) ;
Dart dd = m_map.phi2(d) ; Dart dd = m_map.phi2(d) ;
m_map.setCurrentLevel(eLevel + 1) ; m_map.setCurrentLevel(eLevel + 1) ;
m_map.cutEdge(d) ; m_map.cutEdge(d) ;
unsigned int eId = m_map.getEdgeId(d) ; unsigned int eId = m_map.getEdgeId(d) ;
m_map.setEdgeId(m_map.phi1(d), eId) ; m_map.setEdgeId(m_map.phi1(d), eId) ;
m_map.setEdgeId(m_map.phi1(dd), eId) ; m_map.setEdgeId(m_map.phi1(dd), eId) ;
(*edgeVertexFunctor)(m_map.phi1(d)) ; (*edgeVertexFunctor)(m_map.phi1(d)) ;
m_map.setCurrentLevel(cur) ; m_map.setCurrentLevel(cur) ;
......
...@@ -143,7 +143,7 @@ public: ...@@ -143,7 +143,7 @@ public:
void splitFace(Dart d, Dart e) ; void splitFace(Dart d, Dart e) ;
unsigned int vertexDegree(Dart d); unsigned int vertexDegree(Dart d);
/*************************************************** /***************************************************
* LEVELS MANAGEMENT * * LEVELS MANAGEMENT *
......
...@@ -163,7 +163,6 @@ public: ...@@ -163,7 +163,6 @@ public:
* MAP MANIPULATION * * MAP MANIPULATION *
***************************************************/ ***************************************************/
Dart cutEdge(Dart d);
/*************************************************** /***************************************************
* LEVELS MANAGEMENT * * LEVELS MANAGEMENT *
...@@ -206,9 +205,9 @@ public: ...@@ -206,9 +205,9 @@ public:
void setEdgeId(Dart d, unsigned int i); //TODO a virer void setEdgeId(Dart d, unsigned int i); //TODO a virer
void setDartEdgeId(Dart d, unsigned int i); void setDartEdgeId(Dart d, unsigned int i);
unsigned int getTriRefinementEdgeId(Dart d); unsigned int triRefinementEdgeId(Dart d);
unsigned int getQuadRefinementEdgeId(Dart d); unsigned int quadRefinementEdgeId(Dart d);
...@@ -228,6 +227,8 @@ public: ...@@ -228,6 +227,8 @@ public:
*/ */
unsigned int getFaceId(Dart d) ; unsigned int getFaceId(Dart d) ;
unsigned int faceId(Dart d);
//! Set a face id to all darts from an orbit of d //! Set a face id to all darts from an orbit of d
/*! /*!
*/ */
......
...@@ -575,14 +575,14 @@ inline unsigned int ImplicitHierarchicalMap3::faceId(Dart d) ...@@ -575,14 +575,14 @@ inline unsigned int ImplicitHierarchicalMap3::faceId(Dart d)
if(fId == 0) if(fId == 0)
return 1; return 1;
else if(id == 1) else if(fId == 1)
return 2; return 2;
else if(id == 2) else if(fId == 2)
{ {
if(dId == eId) // if(dId == eId)
return 0; return 0;
else // else
return 1; // return 1;
} }
//else if(id == 3) //else if(id == 3)
......
...@@ -122,6 +122,11 @@ public: ...@@ -122,6 +122,11 @@ public:
*/ */
virtual void splitVolume(std::vector<Dart>& vd); virtual void splitVolume(std::vector<Dart>& vd);
//!
/*!
*/
virtual void cutVolume(std::vector<Dart>& vd);
//! //!
virtual void splitVolumeWithFace(std::vector<Dart>& vd, Dart d); virtual void splitVolumeWithFace(std::vector<Dart>& vd, Dart d);
......
...@@ -694,7 +694,7 @@ void Map2<MAP_IMPL>::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, b ...@@ -694,7 +694,7 @@ void Map2<MAP_IMPL>::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, b
//unsew the edge path //unsew the edge path
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it) for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
{ {
//if(!Map2<MAP_IMPL>::isBoundaryEdge(*it)) if(!Map2<MAP_IMPL>::isBoundaryEdge(*it))
unsewFaces(*it) ; unsewFaces(*it) ;
} }
......
...@@ -272,6 +272,11 @@ public: ...@@ -272,6 +272,11 @@ public:
*/ */
virtual void splitVolume(std::vector<Dart>& vd); virtual void splitVolume(std::vector<Dart>& vd);
//! Split a volume into two volumes along a edge path by creating a hole between them
/*! @param vd a vector of darts
*/
virtual void cutVolume(std::vector<Dart>& vd);
//! Split a volume into two volumes along a edge path and add the given face between //! Split a volume into two volumes along a edge path and add the given face between
virtual void splitVolumeWithFace(std::vector<Dart>& vd, Dart d); virtual void splitVolumeWithFace(std::vector<Dart>& vd, Dart d);
......
...@@ -775,6 +775,52 @@ void Map3<MAP_IMPL>::splitVolume(std::vector<Dart>& vd) ...@@ -775,6 +775,52 @@ void Map3<MAP_IMPL>::splitVolume(std::vector<Dart>& vd)
Map3<MAP_IMPL>::sewVolumes(this->phi2(e), this->phi2(e2), false); Map3<MAP_IMPL>::sewVolumes(this->phi2(e), this->phi2(e2), false);
} }
template <typename MAP_IMPL>
void Map3<MAP_IMPL>::cutVolume(std::vector<Dart>& vd)
{
//assert(checkSimpleOrientedPath(vd));
Dart e = vd.front();
Dart e2 = this->phi2(e);
//cut the volume following the path
ParentMap::splitSurface(vd, true, true);
//create the boundary
Dart b1 = newBoundaryCycle(vd.size());
Dart b2 = newBoundaryCycle(vd.size());
Dart fit1 = this->phi2(e);
Dart fit2 = this->phi2(e2);
Dart fitB1 = b1;
Dart fitB2 = b2;
do
{
Dart f = findBoundaryFaceOfEdge(fit1) ;
if(f != NIL)
{
Dart f2 = this->phi2(f) ;
this->phi2unsew(f) ;
this->phi2sew(fitB1, f) ;
this->phi2sew(fitB2, f2) ;
}
else
this->phi2sew(fitB1, fitB2) ;
//no phi3unsew for fit1 : already unsewed
phi3unsew(fit1) ;
phi3sew(fit1, fitB1);
phi3sew(fit2, fitB2);
fit1 = this->phi1(fit1);
fit2 = this->phi_1(fit2);
fitB1 = this->phi_1(fitB1);
fitB2 = this->phi1(fitB2);
} while(fitB1 != b1);
}
template <typename MAP_IMPL> template <typename MAP_IMPL>
void Map3<MAP_IMPL>::splitVolumeWithFace(std::vector<Dart>& vd, Dart d) void Map3<MAP_IMPL>::splitVolumeWithFace(std::vector<Dart>& vd, Dart d)
{ {
...@@ -1428,7 +1474,7 @@ unsigned int Map3<MAP_IMPL>::closeMap() ...@@ -1428,7 +1474,7 @@ unsigned int Map3<MAP_IMPL>::closeMap()
if (phi3(d) == d) if (phi3(d) == d)
{ {
++nb ; ++nb ;
closeHole(d,true); closeHole(d);
} }
} }
return nb ; return nb ;
......
...@@ -62,12 +62,12 @@ void ImplicitHierarchicalMap3::clear(bool removeAttrib) ...@@ -62,12 +62,12 @@ void ImplicitHierarchicalMap3::clear(bool removeAttrib)
void ImplicitHierarchicalMap3::initImplicitProperties() void ImplicitHierarchicalMap3::initImplicitProperties()
{ {
//initEdgeId() ; //initEdgeId() ;
initFaceId(); //initFaceId();
for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d)) for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
{ {
m_edgeId[d] = 0; m_edgeId[d] = 0;
//m_faceId[d] = 0; m_faceId[d] = 0;
} }
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
...@@ -130,19 +130,4 @@ void ImplicitHierarchicalMap3::initFaceId() ...@@ -130,19 +130,4 @@ void ImplicitHierarchicalMap3::initFaceId()
} }
} }
Dart ImplicitHierarchicalMap3::cutEdge(Dart d)
{
Dart nd = EmbeddedMap3::cutEdge(d);
// unsigned int id = getEdgeId(d);
// setEdgeId(nd, id);
// setEdgeId(phi2(d), id);
// setFaceId(EDGE, nd);
// m_faceId[]
return nd;
}
} //namespace CGoGN } //namespace CGoGN
...@@ -488,6 +488,64 @@ void EmbeddedMap3::splitVolume(std::vector<Dart>& vd) ...@@ -488,6 +488,64 @@ void EmbeddedMap3::splitVolume(std::vector<Dart>& vd)
} }
} }
void EmbeddedMap3::cutVolume(std::vector<Dart>& vd)
{
Map3::cutVolume(vd);
// follow the edge path a second time to embed the vertex, edge and volume orbits
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
{
Dart dit = *it;
Dart dit23 = phi3(phi2(dit));