ihm2.cpp 9.69 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
///*******************************************************************************
//* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
//* version 0.1                                                                  *
//* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
//*                                                                              *
//* This library is free software; you can redistribute it and/or modify it      *
//* under the terms of the GNU Lesser General Public License as published by the *
//* Free Software Foundation; either version 2.1 of the License, or (at your     *
//* option) any later version.                                                   *
//*                                                                              *
//* This library is distributed in the hope that it will be useful, but WITHOUT  *
//* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
//* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
//* for more details.                                                            *
//*                                                                              *
//* You should have received a copy of the GNU Lesser General Public License     *
//* along with this library; if not, write to the Free Software Foundation,      *
//* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
//*                                                                              *
//* Web site: http://cgogn.unistra.fr/                                           *
//* Contact information: cgogn@unistra.fr                                        *
//*                                                                              *
//*******************************************************************************/
//
//#define CGoGN_TOPO_DLL_EXPORT 1
//
//#include "Topology/ihmap/ihm2.h"
//
//#include <cmath>
//
//
//namespace CGoGN
33
//{
Sylvain Thery's avatar
Sylvain Thery committed
34 35
//
//ImplicitHierarchicalMap2::ImplicitHierarchicalMap2() : m_curLevel(0), m_maxLevel(0), m_idCount(0)
36
//{
Sylvain Thery's avatar
Sylvain Thery committed
37 38 39 40
//	m_dartLevel = Map2::addAttribute<unsigned int, DART, ImplicitHierarchicalMap2>("dartLevel") ;
//	m_edgeId = Map2::addAttribute<unsigned int, DART, ImplicitHierarchicalMap2>("edgeId") ;
//	for(unsigned int i = 0; i < NB_ORBITS; ++i)
//		m_nextLevelCell[i] = NULL ;
41
//}
Sylvain Thery's avatar
Sylvain Thery committed
42 43
//
//ImplicitHierarchicalMap2::~ImplicitHierarchicalMap2()
44
//{
Sylvain Thery's avatar
Sylvain Thery committed
45 46
//	removeAttribute(m_edgeId) ;
//	removeAttribute(m_dartLevel) ;
47
//}
Sylvain Thery's avatar
Sylvain Thery committed
48 49
//
//void ImplicitHierarchicalMap2::clear(bool removeAttrib)
50
//{
Sylvain Thery's avatar
Sylvain Thery committed
51 52 53 54 55 56 57 58 59
//	Map2::clear(removeAttrib) ;
//	if (removeAttrib)
//	{
//		m_dartLevel = Map2::addAttribute<unsigned int, DART, ImplicitHierarchicalMap2>("dartLevel") ;
//		m_edgeId = Map2::addAttribute<unsigned int, DART, ImplicitHierarchicalMap2>("edgeId") ;
//
//		for(unsigned int i = 0; i < NB_ORBITS; ++i)
//			m_nextLevelCell[i] = NULL ;
//	}
60
//}
Sylvain Thery's avatar
Sylvain Thery committed
61 62
//
//void ImplicitHierarchicalMap2::initImplicitProperties()
63
//{
Sylvain Thery's avatar
Sylvain Thery committed
64 65 66 67 68 69 70 71 72
//	//initEdgeId() ;
//
//	//init each edge Id at 0
//	for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d))
//	{
//		m_edgeId[d] = 0;
//	}
//
//	for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
73
//	{
Sylvain Thery's avatar
Sylvain Thery committed
74
//		if(m_nextLevelCell[orbit] != NULL)
75
//		{
Sylvain Thery's avatar
Sylvain Thery committed
76 77 78
//			AttributeContainer& cellCont = m_attribs[orbit] ;
//			for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
//				m_nextLevelCell[orbit]->operator[](i) = EMBNULL ;
79 80 81
//		}
//	}
//}
Sylvain Thery's avatar
Sylvain Thery committed
82 83
//
//void ImplicitHierarchicalMap2::initEdgeId()
84
//{
Sylvain Thery's avatar
Sylvain Thery committed
85 86 87
//	m_idCount = 0 ;
//	DartMarker<Map2> edgeMark(*this) ;
//	for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d))
88
//	{
Sylvain Thery's avatar
Sylvain Thery committed
89
//		if(!edgeMark.isMarked(d))
90
//		{
Sylvain Thery's avatar
Sylvain Thery committed
91 92 93
//			edgeMark.markOrbit<EDGE>(d) ;
//			m_edgeId[d] = m_idCount ;
//			m_edgeId[Map2::phi2(d)] = m_idCount++ ;
94 95 96
//		}
//	}
//}
Sylvain Thery's avatar
Sylvain Thery committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
//
//unsigned int ImplicitHierarchicalMap2::vertexDegree(Dart d)
//{
//    unsigned int count = 0 ;
//    Dart it = d ;
//    do
//    {
//        ++count ;
//        it = phi2(phi_1(it)) ;
//    } while (it != d) ;
//    return count ;
//}
//
////unsigned int ImplicitHierarchicalMap2::faceLevel(Dart d)
////{
////	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//
////	if(m_curLevel == 0)
////		return 0 ;
//
//////	unsigned int cur = m_curLevel ;
//////	Dart it = d ;
//////	Dart end = d ;
//////	bool resetEnd = true ;
//////	bool firstEdge = true ;
//////	do
//////	{
//////		if(!resetEnd)
//////			firstEdge = false ;
//////
//////		unsigned int eId = m_edgeId[it] ;
//////		Dart next = it ;
//////		do
//////		{
//////			unsigned int l = edgeLevel(next) ;
//////			if(l < m_curLevel)
//////				m_curLevel = l ;
//////			else // l == curLevel
//////			{
//////				if(!firstEdge)
//////				{
//////					--m_curLevel ;
//////					next = it ;
//////				}
//////			}
//////			next = phi1(next) ;
//////		} while(m_edgeId[next] == eId) ;
//////		it = next ;
//////
//////		if(resetEnd)
//////		{
//////			end = it ;
//////			resetEnd = false ;
//////		}
//////
//////	} while(!firstEdge && it != end) ;
//////
//////	unsigned int fLevel = m_curLevel ;
//////	m_curLevel = cur ;
//
////	Dart it = d ;
////	Dart old = it ;
////	unsigned int l_old = m_dartLevel[old] ;
////	unsigned int fLevel = edgeLevel(it) ;
////	do
////	{
////		it = phi1(it) ;
////		unsigned int dl = m_dartLevel[it] ;
////		if(dl < l_old)							// compute the oldest dart of the face
////		{										// in the same time
////			old = it ;
////			l_old = dl ;
////		}										// in a first time, the level of a face
////		unsigned int l = edgeLevel(it) ;		// is the minimum of the levels
////		fLevel = l < fLevel ? l : fLevel ;		// of its edges
////	} while(it != d) ;
//
////	unsigned int cur = m_curLevel ;
////	m_curLevel = fLevel ;
//
////	unsigned int nbSubd = 0 ;
////	it = old ;
////	unsigned int eId = m_edgeId[old] ;			// the particular case of a face
////	do											// with all neighboring faces regularly subdivided
////	{											// but not the face itself
////		++nbSubd ;								// is treated here
////		it = phi1(it) ;
////	} while(m_edgeId[it] == eId) ;
//
////	while(nbSubd > 1)
////	{
////		nbSubd /= 2 ;
////		--fLevel ;
////	}
//
////	m_curLevel = cur ;
//
////	return fLevel ;
////}
//
////Dart ImplicitHierarchicalMap2::faceOrigin(Dart d)
////{
////	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
////	unsigned int cur = m_curLevel ;
////	Dart p = d ;
////	unsigned int pLevel = m_dartLevel[p] ;
////	while(pLevel > 0)
////	{
////		p = faceOldestDart(p) ;
////		pLevel = m_dartLevel[p] ;
////		m_curLevel = pLevel ;
////	}
////	m_curLevel = cur ;
////	return p ;
////}
//
////Dart ImplicitHierarchicalMap2::faceOldestDart(Dart d)
////{
////	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
////	Dart it = d ;
////	Dart oldest = it ;
////	unsigned int l_old = m_dartLevel[oldest] ;
////	do
////	{
////		unsigned int l = m_dartLevel[it] ;
////		if(l == 0)
////			return it ;
////		if(l < l_old)
//////		if(l < l_old || (l == l_old && it < oldest))
////		{
////			oldest = it ;
////			l_old = l ;
////		}
////		it = phi1(it) ;
////	} while(it != d) ;
////	return oldest ;
////}
//
////bool ImplicitHierarchicalMap2::edgeIsSubdivided(Dart d)
////{
////	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//////	Dart d2 = phi2(d) ;
////	Dart d1 = phi1(d) ;
////	++m_curLevel ;
//////	Dart d2_l = phi2(d) ;
////	Dart d1_l = phi1(d) ;
////	--m_curLevel ;
////	if(d1 != d1_l)
////		return true ;
////	else
////		return false ;
////}
//
////bool ImplicitHierarchicalMap2::edgeCanBeCoarsened(Dart d)
////{
////	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
////	bool subd = false ;
////	bool subdOnce = true ;
////	bool degree2 = false ;
////	if(edgeIsSubdivided(d))
////	{
////		subd = true ;
////		Dart d2 = phi2(d) ;
////		++m_curLevel ;
////		if(vertexDegree(phi1(d)) == 2)
////		{
////			degree2 = true ;
////			if(edgeIsSubdivided(d) || edgeIsSubdivided(d2))
////				subdOnce = false ;
////		}
////		--m_curLevel ;
////	}
////	return subd && degree2 && subdOnce ;
////}
//
////bool ImplicitHierarchicalMap2::faceIsSubdivided(Dart d)
////{
////	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
////	unsigned int fLevel = faceLevel(d) ;
////	if(fLevel < m_curLevel)
////		return false ;
//
////	bool subd = false ;
////	++m_curLevel ;
////	if(m_dartLevel[phi1(d)] == m_curLevel && m_edgeId[phi1(d)] != m_edgeId[d])
////		subd = true ;
////	--m_curLevel ;
////	return subd ;
////}
//
////bool ImplicitHierarchicalMap2::faceIsSubdividedOnce(Dart d)
////{
////	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
////	unsigned int fLevel = faceLevel(d) ;
////	if(fLevel < m_curLevel)		// a face whose level in the current level map is lower than
////		return false ;			// the current level can not be subdivided to higher levels
//
////	unsigned int degree = 0 ;
////	bool subd = false ;
////	bool subdOnce = true ;
////	Dart fit = d ;
////	do
////	{
////		++m_curLevel ;
////		if(m_dartLevel[phi1(fit)] == m_curLevel && m_edgeId[phi1(fit)] != m_edgeId[fit])
////		{
////			subd = true ;
////			++m_curLevel ;
////			if(m_dartLevel[phi1(fit)] == m_curLevel && m_edgeId[phi1(fit)] != m_edgeId[fit])
////				subdOnce = false ;
////			--m_curLevel ;
////		}
////		--m_curLevel ;
////		++degree ;
////		fit = phi1(fit) ;
////	} while(subd && subdOnce && fit != d) ;
//
////	if(degree == 3 && subd)
////	{
////		++m_curLevel ;
////		Dart cf = phi2(phi1(d)) ;
////		++m_curLevel ;
////		if(m_dartLevel[phi1(cf)] == m_curLevel && m_edgeId[phi1(cf)] != m_edgeId[cf])
////			subdOnce = false ;
////		--m_curLevel ;
////		--m_curLevel ;
////	}
//
////	return subd && subdOnce ;
////}
//
//} //namespace CGoGN