ihm3.cpp 4.92 KB
Newer Older
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
/*******************************************************************************
* 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                                        *
*                                                                              *
*******************************************************************************/

#include "Topology/ihmap/ihm3.h"
#include <math.h>

namespace CGoGN
{

ImplicitHierarchicalMap3::ImplicitHierarchicalMap3() : m_curLevel(0), m_maxLevel(0), m_edgeIdCount(0), m_faceIdCount(0)
{
    m_dartLevel = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("dartLevel") ;
    m_edgeId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("edgeId") ;
    m_faceId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("faceId") ;

    for(unsigned int i = 0; i < NB_ORBITS; ++i)
        m_nextLevelCell[i] = NULL ;
}

ImplicitHierarchicalMap3::~ImplicitHierarchicalMap3()
{
    removeAttribute(m_edgeId) ;
    removeAttribute(m_faceId) ;
    removeAttribute(m_dartLevel) ;
}

void ImplicitHierarchicalMap3::clear(bool removeAttrib)
{
    Map3::clear(removeAttrib) ;
    if (removeAttrib)
    {
        m_dartLevel = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("dartLevel") ;
        m_faceId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("faceId") ;
        m_edgeId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("edgeId") ;

        for(unsigned int i = 0; i < NB_ORBITS; ++i)
            m_nextLevelCell[i] = NULL ;
    }
}

void ImplicitHierarchicalMap3::initImplicitProperties()
{
64
	//initEdgeId() ;
65 66
    initFaceId();

67 68 69 70 71
	for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
	{
		m_edgeId[d] = 0;
		//m_faceId[d] = 0;
	}
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 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

    for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
    {
        if(m_nextLevelCell[orbit] != NULL)
        {
            AttributeContainer& cellCont = m_attribs[orbit] ;
            for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
                m_nextLevelCell[orbit]->operator[](i) = EMBNULL ;
        }
    }
}

void ImplicitHierarchicalMap3::initEdgeId()
{
    DartMarkerStore<Map3> edgeMark(*this) ;
    for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
    {
        if(!edgeMark.isMarked(d))
        {
            Dart e = d;
            do
            {
                m_edgeId[e] = m_edgeIdCount;
                edgeMark.mark(e);

                m_edgeId[Map3::phi2(e)] = m_edgeIdCount ;
                edgeMark.mark(Map3::phi2(e));

                e = Map3::alpha2(e);
            } while(e != d);

            m_edgeIdCount++;
        }
    }
}

void ImplicitHierarchicalMap3::initFaceId()
{
    DartMarkerStore<Map3> faceMark(*this) ;
    for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
    {
        if(!faceMark.isMarked(d))
        {
            Dart e = d;
            do
            {
                m_faceId[e] = m_faceIdCount ;
                faceMark.mark(e);

                Dart e3 = Map3::phi3(e);
                m_faceId[e3] = m_faceIdCount ;
                faceMark.mark(e3);

                e = Map3::phi1(e);
            } while(e != d);

            m_faceIdCount++;
        }
    }
}

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
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;
}

148
} //namespace CGoGN