Ejemplo n.º 1
0
        bool loadExemplarData(StreamReader f)
        {
            //grab our ID
            m_iExemplarId = Convert.ToInt32(f.ReadLine());

            // read exemplar flags
            int flags = Convert.ToInt32(f.ReadLine());

            m_bToroidal = (flags & (int)eExemplarFlags.EXEMPLAR_TOROIDAL_FLAG) != 0 ? true : false;

            // read periods
            m_iPeriodX = Convert.ToInt32(f.ReadLine());
            m_iPeriodY = Convert.ToInt32(f.ReadLine());

            // read number of levels
            m_iNbLevels = Convert.ToInt32(f.ReadLine());

            // read exemplar name & load our image stack
            String exname = f.ReadLine();
            MultiDimFloatTexture image = new MultiDimFloatTexture(exname);

            {
                bool succede = computeStackLevels(image, m_bToroidal, ref m_Stack) == m_iNbLevels;
                Globals.Assert(succede);
            }
            m_Stack[0].setName(image.getName());



            //read our presentation flagss
            String name    = null;
            int    present = Convert.ToInt32(f.ReadLine());

            if ((present & (int)eExemplarFlags.FLAG_CONSTRAINT) != 0)
            {
                // read constraint texture name
                name = f.ReadLine();
                MultiDimFloatTexture constraint = new MultiDimFloatTexture(name);
                {
                    bool succede = (computeStackLevels(constraint, m_bToroidal, ref m_Constraints) == m_iNbLevels);
                    Globals.Assert(succede);
                }
                m_Constraints[0].setName(constraint.getName());
            }
            if ((present & (int)eExemplarFlags.FLAG_FMAP) != 0)
            {
                // NOTE: feature map is no longer saved
                //       this is done for backward comp.
                name = f.ReadLine();
            }
            if ((present & (int)eExemplarFlags.FLAG_PRTCOLORMAP) != 0)
            {
                name = f.ReadLine();
                //m_PRTColorMap=CTexture::loadTexture(name.c_str());
            }


            //load our Knearest neighbors (see TONG et al. 2002 "Synthesis of bidirectional texture functions on arbitrary surfaces.")
            mKNS = new KNearestSimilartySet(f, this, m_iNbLevels);



            // load recolored exemplar (see HOPPE et al. 2006 "Appearance Space Texture Synthesis")
            m_RecoloredStack = new MultiDimFloatTexture[m_iNbLevels];
            for (int l = 0; l < m_iNbLevels; l++)
            {
                name = f.ReadLine();
                m_RecoloredStack[l] = new MultiDimFloatTexture(name);
            }

            loadHighResExemplarImg(m_name);
            loadRandomTexture(m_name);

            return(true);
        }