Commit c8558691 authored by Lionel Untereiner's avatar Lionel Untereiner

some changes

parent 38233cd7
......@@ -170,7 +170,8 @@ void MCMesh::updateRender()
void MCMesh::fromFile(char* fname)
{
myImg = new SAlgo::MC::Image<DATATYPE>();
myImg->loadInrgz(fname);
//myImg->loadInrgz(fname);
myImg->loadVox(fname);
CGoGNout << "Image chargee"<<CGoGNendl;
CGoGNout << myImg->getWidthX() <<"x"<< myImg->getWidthY() <<"x"<< myImg->getWidthZ() << "voxels"<<CGoGNendl;
}
......
......@@ -157,6 +157,17 @@ void MyQT::operation(int x)
m_selected2=NIL;
}
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:
break;
......@@ -256,6 +267,12 @@ void MyQT::cb_redraw()
if (m_selected2 != NIL)
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)
......@@ -275,6 +292,17 @@ void MyQT::cb_mousePress(int button, int x, int y)
}
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)
......
......@@ -94,6 +94,7 @@ protected:
#endif
Dart m_selected;
Dart m_selected2;
std::vector<Dart> m_selecteds;
DartMarker<MAP> dm;
float m_shift;
......
......@@ -36,7 +36,16 @@
</size>
</property>
<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>
</property>
<property name="spacing">
......@@ -99,6 +108,11 @@
<string>deleteFace</string>
</property>
</item>
<item>
<property name="text">
<string>splitSurface</string>
</property>
</item>
</widget>
</item>
<item>
......
......@@ -248,6 +248,24 @@ void MyQT::operation(int x)
updateMap();
}
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:
break;
}
......@@ -470,12 +488,12 @@ void MyQT::cb_mousePress(int button, int x, int y)
{
if (button == Qt::LeftButton)
{
Dart d = m_render_topo_boundary->picking(myMap, x,y,true);
if (d != Dart::nil())
{
Dart e = myMap.phi2(d);
std::cout << "Dart "<< d.index << " / phi2:" << e.index << std::endl;
}
m_selecteds.push_back(Dart(173));
m_selecteds.push_back(Dart(186));
m_selecteds.push_back(Dart(185));
m_selecteds.push_back(Dart(171));
m_selecteds.push_back(Dart(170));
m_selecteds.push_back(Dart(174));
}
if (button == Qt::RightButton)
{
......@@ -483,8 +501,6 @@ void MyQT::cb_mousePress(int button, int x, int y)
if (d != Dart::nil())
{
m_selecteds.push_back(d);
Dart e = myMap.phi2(d);
std::cout << "Dart "<< d.index << " / phi2:" << e.index << std::endl;
}
}
......
......@@ -155,6 +155,16 @@
<string>deleteVolume</string>
</property>
</item>
<item>
<property name="text">
<string>splitVolume</string>
</property>
</item>
<item>
<property name="text">
<string>cutVolume</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
......
......@@ -14,3 +14,5 @@ ADD_SUBDIRECTORY(surface_modelisation)
ADD_SUBDIRECTORY(volume_import)
#ADD_SUBDIRECTORY(volume_render)
ADD_SUBDIRECTORY(volumetric)
#ifndef _TEXTURE_H_
#define _TEXTURE_H_
#include "Utils/gl_def.h"
#include <QSize>
namespace CGoGN
{
......
......@@ -39,6 +39,7 @@ class Camera;
class MapHandlerGen;
class CellSelectorGen;
struct Texture;
class ObjectHandlerGen;
typedef QMap<QString, Plugin*> PluginSet;
typedef QMap<QString, View*> ViewSet;
......@@ -51,6 +52,8 @@ typedef QMap<QString, Utils::GLSLShader*> ShaderSet;
typedef QMap<QString, Texture*> TextureSet;
typedef QMap<QString, ObjectHandlerGen*> ObjectSet;
} // namespace SCHNApps
} // namespace CGoGN
......
......@@ -78,12 +78,7 @@ IF(WIN32)
ELSE(WIN32)
find_package(SuiteSparse REQUIRED)
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} )
>>>>>>> c2fbbbce446c3f437c531debda00b48f13f29790
ENDIF(WIN32)
#optionnal libs
......
......@@ -195,12 +195,12 @@ public:
/**
* Load a raw image
*/
void loadRaw(char *filename);
void loadRaw(const char *filename);
/**
* Load a vox file
*/
void loadVox(char *filename);
void loadVox(const char *filename);
/**
* save current image into file
......
......@@ -115,7 +115,7 @@ void Image<DataType>::createMask(const Image<DataTypeIn>& img )
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);
if (!fp.good())
......@@ -147,7 +147,7 @@ void Image<DataType>::loadRaw(char *filename)
template< typename DataType >
void Image<DataType>::loadVox(char *filename)
void Image<DataType>::loadVox(const char *filename)
{
std::ifstream in(filename);
if (!in)
......
......@@ -312,14 +312,14 @@ void IHM2<PFP>::subdivideEdge(Dart d)
unsigned int cur = m_map.getCurrentLevel() ;
m_map.setCurrentLevel(eLevel) ;
Dart dd = m_map.phi2(d) ;
Dart dd = m_map.phi2(d) ;
m_map.setCurrentLevel(eLevel + 1) ;
m_map.cutEdge(d) ;
unsigned int eId = m_map.getEdgeId(d) ;
m_map.setEdgeId(m_map.phi1(d), eId) ;
m_map.setEdgeId(m_map.phi1(dd), eId) ;
m_map.setEdgeId(m_map.phi1(d), eId) ;
m_map.setEdgeId(m_map.phi1(dd), eId) ;
(*edgeVertexFunctor)(m_map.phi1(d)) ;
m_map.setCurrentLevel(cur) ;
......
......@@ -143,7 +143,7 @@ public:
void splitFace(Dart d, Dart e) ;
unsigned int vertexDegree(Dart d);
unsigned int vertexDegree(Dart d);
/***************************************************
* LEVELS MANAGEMENT *
......
......@@ -163,7 +163,6 @@ public:
* MAP MANIPULATION *
***************************************************/
Dart cutEdge(Dart d);
/***************************************************
* LEVELS MANAGEMENT *
......@@ -206,9 +205,9 @@ public:
void setEdgeId(Dart d, unsigned int i); //TODO a virer
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:
*/
unsigned int getFaceId(Dart d) ;
unsigned int faceId(Dart d);
//! Set a face id to all darts from an orbit of d
/*!
*/
......
......@@ -575,14 +575,14 @@ inline unsigned int ImplicitHierarchicalMap3::faceId(Dart d)
if(fId == 0)
return 1;
else if(id == 1)
else if(fId == 1)
return 2;
else if(id == 2)
else if(fId == 2)
{
if(dId == eId)
// if(dId == eId)
return 0;
else
return 1;
// else
// return 1;
}
//else if(id == 3)
......
......@@ -122,6 +122,11 @@ public:
*/
virtual void splitVolume(std::vector<Dart>& vd);
//!
/*!
*/
virtual void cutVolume(std::vector<Dart>& vd);
//!
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
//unsew the edge path
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) ;
}
......
......@@ -272,6 +272,11 @@ public:
*/
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
virtual void splitVolumeWithFace(std::vector<Dart>& vd, Dart d);
......
......@@ -775,6 +775,52 @@ void Map3<MAP_IMPL>::splitVolume(std::vector<Dart>& vd)
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>
void Map3<MAP_IMPL>::splitVolumeWithFace(std::vector<Dart>& vd, Dart d)
{
......@@ -1428,7 +1474,7 @@ unsigned int Map3<MAP_IMPL>::closeMap()
if (phi3(d) == d)
{
++nb ;
closeHole(d,true);
closeHole(d);
}
}
return nb ;
......
......@@ -62,12 +62,12 @@ void ImplicitHierarchicalMap3::clear(bool removeAttrib)
void ImplicitHierarchicalMap3::initImplicitProperties()
{
//initEdgeId() ;
initFaceId();
//initFaceId();
for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
{
m_edgeId[d] = 0;
//m_faceId[d] = 0;
m_faceId[d] = 0;
}
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
......@@ -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
......@@ -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));
// embed the vertex embedded from the origin volume to the new darts
if(isOrbitEmbedded<VERTEX>())
{
// if(!sameVertex(dit, dd))
// {
// Algo::Topo::setOrbitEmbedding<VERTEX>(*this, dit, getEmbedding<VERTEX>(dit)) ;
// Algo::Topo::setOrbitEmbeddingOnNewCell<VERTEX>(*this, dit23);
// Algo::Topo::copyCellAttributes<VERTEX>(*this, dit23, dit);
// }
// else
// {
// Algo::Topo::setOrbitEmbedding<VERTEX>(*this, dit, getEmbedding<VERTEX>(dit)) ;
// }
}
// embed the edge embedded from the origin volume to the new darts
if(isOrbitEmbedded<EDGE>())
{
if(!sameEdge(dit, dit23))
{
Algo::Topo::setOrbitEmbeddingOnNewCell<EDGE>(*this, dit23);
Algo::Topo::copyCellAttributes<EDGE>(*this, dit23, dit);
copyDartEmbedding<EDGE>(phi3(dit), dit) ;
}
else
{
unsigned int eEmb = getEmbedding<EDGE>(dit) ;
setDartEmbedding<EDGE>(phi3(dit), eEmb) ;
setDartEmbedding<EDGE>(alpha_2(dit), eEmb) ;
}
}
// embed the volume embedded from the origin volume to the new darts
if(isOrbitEmbedded<VOLUME>())
{
copyDartEmbedding<VOLUME>(phi2(dit), dit);
}
}
if(isOrbitEmbedded<VOLUME>())
{
Dart v = vd.front() ;
Dart v23 = phi3(phi2(v));
Algo::Topo::setOrbitEmbeddingOnNewCell<VOLUME>(*this, v23) ;
Algo::Topo::copyCellAttributes<VOLUME>(*this, v23, v) ;
}
}
//! Split a volume into two volumes along a edge path and add the given face between
void EmbeddedMap3::splitVolumeWithFace(std::vector<Dart>& vd, Dart d)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment