inline void FinalSnapshot ( const Matrix<Real>& estimates, const Matrix<Int>& itCounts, SnapshotCtrl& snapCtrl ) { DEBUG_ONLY(CSE cse("pspec::FinalSnapshot")); auto logMap = []( Real alpha ) { return Log(alpha); }; if( snapCtrl.realSize != 0 && snapCtrl.imagSize != 0 ) { const bool numSave = ( snapCtrl.numSaveFreq >= 0 ); const bool imgSave = ( snapCtrl.imgSaveFreq >= 0 ); const bool imgDisp = ( snapCtrl.imgDispFreq >= 0 ); Matrix<Real> estMap; Matrix<Int> itCountMap; if( numSave || imgSave || imgDisp ) { ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, estimates, estMap ); if( snapCtrl.itCounts ) ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, itCounts, itCountMap ); } if( numSave ) { string base = snapCtrl.numBase; Write( estMap, base, snapCtrl.numFormat ); if( snapCtrl.itCounts ) Write( itCountMap, base+"_counts", snapCtrl.numFormat ); } if( imgSave || imgDisp ) EntrywiseMap( estMap, function<Real(Real)>(logMap) ); if( imgSave ) { string base = snapCtrl.imgBase; Write( estMap, base, snapCtrl.imgFormat ); if( snapCtrl.itCounts ) Write( itCountMap, base+"_counts", snapCtrl.imgFormat ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Write( estMap, base+"_discrete", snapCtrl.imgFormat ); SetColorMap( colorMap ); } if( imgDisp ) { string base = snapCtrl.imgBase; Display( estMap, base ); if( snapCtrl.itCounts ) Display( itCountMap, base+"_counts" ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Display( estMap, base+"_discrete" ); SetColorMap( colorMap ); } } }
void FinalSnapshot ( const DistMatrix<Real,VR,STAR>& estimates, const DistMatrix<Int, VR,STAR>& itCounts, SnapshotCtrl& snapCtrl ) { EL_DEBUG_CSE auto logMap = []( const Real& alpha ) { return Log(alpha); }; if( snapCtrl.realSize != 0 && snapCtrl.imagSize != 0 ) { const bool numSave = ( snapCtrl.numSaveFreq >= 0 ); const bool imgSave = ( snapCtrl.imgSaveFreq >= 0 ); const bool imgDisp = ( snapCtrl.imgDispFreq >= 0 ); DistMatrix<Real> estMap(estimates.Grid()); DistMatrix<Int> itCountMap(itCounts.Grid()); if( numSave || imgSave || imgDisp ) { ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, estimates, estMap ); if( snapCtrl.itCounts ) ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, itCounts, itCountMap ); } if( numSave ) { string base = snapCtrl.numBase; Write( estMap, base, snapCtrl.numFormat ); if( snapCtrl.itCounts ) Write( itCountMap, base+"_counts", snapCtrl.numFormat ); } if( imgSave || imgDisp ) EntrywiseMap( estMap, MakeFunction(logMap) ); if( imgSave ) { string base = snapCtrl.imgBase; Write( estMap, base, snapCtrl.imgFormat ); if( snapCtrl.itCounts ) Write( itCountMap, base+"_counts", snapCtrl.imgFormat ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Write( estMap, base+"_discrete", snapCtrl.imgFormat ); SetColorMap( colorMap ); } if( imgDisp ) { string base = snapCtrl.imgBase; Display( estMap, base ); if( snapCtrl.itCounts ) Display( itCountMap, base+"_counts" ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Display( estMap, base+"_discrete" ); SetColorMap( colorMap ); } } }
/*! Subdivides the mesh uniformly one step */ void LoopSubdivisionMesh::Subdivide() { // Create new mesh and copy all the attributes HalfEdgeMesh subDivMesh; subDivMesh.SetTransform(GetTransform()); subDivMesh.SetName(GetName()); subDivMesh.SetColorMap(GetColorMap()); subDivMesh.SetWireframe(GetWireframe()); subDivMesh.SetShowNormals(GetShowNormals()); subDivMesh.SetOpacity(GetOpacity()); if (IsHovering()) subDivMesh.Hover(); if (IsSelected()) subDivMesh.Select(); subDivMesh.mMinCMap = mMinCMap; subDivMesh.mMaxCMap = mMaxCMap; subDivMesh.mAutoMinMax = mAutoMinMax; // loop over each face and create 4 new ones for (unsigned int i=0; i<mFaces.size(); i++){ // subdivide face std::vector< std::vector<Vector3<float> > > faces = Subdivide(i); // add new faces to subDivMesh for(unsigned int j=0; j<faces.size(); j++){ subDivMesh.AddFace(faces.at(j)); } } // Assigns the new mesh *this = LoopSubdivisionMesh(subDivMesh, ++mNumSubDivs); Update(); }
ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height, ULONG trans, ULONG pals1, struct ColorRegister *pal1, int alpha) { ULONG *argbicon; struct ColorRegister *colour; struct ColorMap *cmap; int i; ULONG a,r,g,b; if (alpha==0) alpha=0xff; argbicon = (ULONG *)AllocVecTagList(width*height*4, NULL); if (!argbicon) return(NULL); cmap=GetColorMap(pals1); if(!cmap) return(NULL); for(i=0;i<(width*height);i++) { colour = &pal1[icondata[i]]; if(icondata[i] == trans) { a=0x00; } else { a=alpha; } r = colour->red; g = colour->green; b = colour->blue; argbicon[i] = (a << 24) + (r << 16) + (g << 8) + (b); } return(argbicon); }
/*! Subdivides the mesh one step, depending on subdividability */ void AdaptiveLoopSubdivisionMesh::Subdivide() { // Create new mesh and copy all the attributes HalfEdgeMesh subDivMesh; subDivMesh.SetTransform(GetTransform()); subDivMesh.SetName(GetName()); subDivMesh.SetColorMap(GetColorMap()); subDivMesh.SetWireframe(GetWireframe()); subDivMesh.SetShowNormals(GetShowNormals()); subDivMesh.SetOpacity(GetOpacity()); if (IsHovering()) subDivMesh.Hover(); if (IsSelected()) subDivMesh.Select(); subDivMesh.mMinCMap = mMinCMap; subDivMesh.mMaxCMap = mMaxCMap; subDivMesh.mAutoMinMax = mAutoMinMax; // loop over each face and create new ones for(unsigned int i=0; i<GetNumFaces(); i++){ // find neighbor faces unsigned int f1, f2, f3; EdgeIterator eit = GetEdgeIterator( f(i).edge ); f1 = eit.Pair().GetEdgeFaceIndex(); eit.Pair(); f2 = eit.Next().Pair().GetEdgeFaceIndex(); eit.Pair(); f3 = eit.Next().Pair().GetEdgeFaceIndex(); unsigned int numNotSubdividable = !Subdividable(f1) + !Subdividable(f2) + !Subdividable(f3); // Do not subdivide if "self" is not subdividable if(!Subdividable(i)){ numNotSubdividable = 3; } std::vector< std::vector <Vector3<float> > > faces; switch(numNotSubdividable){ case 0: // normal subdivision (from LoopSubdivisionMesh) faces = LoopSubdivisionMesh::Subdivide(i); break; case 1: // special case 1 faces = Subdivide1(i); break; case 2: // special case 2 faces = Subdivide2(i); break; case 3: // trivial case, no subdivision, same as if subdividable(fi) == false faces = Subdivide3(i); break; } // add the faces (if any) to subDivMesh for(unsigned int j=0; j<faces.size(); j++){ subDivMesh.AddFace(faces.at(j)); } } // Assign the new mesh *this = AdaptiveLoopSubdivisionMesh(subDivMesh, ++mNumSubDivs); Update(); }
void Snapshot ( const Matrix<Int>& preimage, const Matrix<Real>& estimates, const Matrix<Int>& itCounts, Int numIts, bool deflate, SnapshotCtrl& snapCtrl ) { EL_DEBUG_CSE auto logMap = []( const Real& alpha ) { return Log(alpha); }; if( snapCtrl.realSize != 0 && snapCtrl.imagSize != 0 ) { const bool numSave = ( snapCtrl.numSaveFreq > 0 && snapCtrl.numSaveCount >= snapCtrl.numSaveFreq ); const bool imgSave = ( snapCtrl.imgSaveFreq > 0 && snapCtrl.imgSaveCount >= snapCtrl.imgSaveFreq ); const bool imgDisp = ( snapCtrl.imgDispFreq > 0 && snapCtrl.imgDispCount >= snapCtrl.imgDispFreq ); Matrix<Real> invNorms, estMap; Matrix<Int> itCountsReord, itCountMap; if( numSave || imgSave || imgDisp ) { invNorms = estimates; if( deflate ) RestoreOrdering( preimage, invNorms ); ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, invNorms, estMap ); if( snapCtrl.itCounts ) { itCountsReord = itCounts; if( deflate ) RestoreOrdering( preimage, itCountsReord ); ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, itCountsReord, itCountMap ); } } if( numSave ) { auto title = BuildString( snapCtrl.numBase, "_", numIts ); Write( estMap, title, snapCtrl.numFormat ); if( snapCtrl.itCounts ) Write( itCountMap, title+"_counts", snapCtrl.numFormat ); snapCtrl.numSaveCount = 0; } if( imgSave || imgDisp ) EntrywiseMap( estMap, MakeFunction(logMap) ); if( imgSave ) { auto title = BuildString( snapCtrl.imgBase, "_", numIts ); Write( estMap, title, snapCtrl.imgFormat ); if( snapCtrl.itCounts ) Write( itCountMap, title+"_counts", snapCtrl.imgFormat ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Write( estMap, title+"_discrete", snapCtrl.imgFormat ); SetColorMap( colorMap ); snapCtrl.imgSaveCount = 0; } if( imgDisp ) { auto title = BuildString( snapCtrl.imgBase, "_", numIts ); Display( estMap, title ); if( snapCtrl.itCounts ) Display( itCountMap, title+"_counts" ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Display( estMap, title+"_discrete" ); SetColorMap( colorMap ); snapCtrl.imgDispCount = 0; } } }
inline void Snapshot ( const Matrix<Int>& preimage, const Matrix<Real>& estimates, const Matrix<Int>& itCounts, Int numIts, bool deflate, SnapshotCtrl& snapCtrl ) { DEBUG_ONLY(CallStackEntry cse("pspec::Snapshot")); if( snapCtrl.realSize != 0 && snapCtrl.imagSize != 0 ) { const bool numSave = ( snapCtrl.numSaveFreq > 0 && snapCtrl.numSaveCount >= snapCtrl.numSaveFreq ); const bool imgSave = ( snapCtrl.imgSaveFreq > 0 && snapCtrl.imgSaveCount >= snapCtrl.imgSaveFreq ); const bool imgDisp = ( snapCtrl.imgDispFreq > 0 && snapCtrl.imgDispCount >= snapCtrl.imgDispFreq ); Matrix<Real> invNorms, estMap; Matrix<Int> itCountsReord, itCountMap; if( numSave || imgSave || imgDisp ) { invNorms = estimates; if( deflate ) RestoreOrdering( preimage, invNorms ); ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, invNorms, estMap ); if( snapCtrl.itCounts ) { itCountsReord = itCounts; if( deflate ) RestoreOrdering( preimage, itCountsReord ); ReshapeIntoGrid ( snapCtrl.realSize, snapCtrl.imagSize, itCountsReord, itCountMap ); } } if( numSave ) { std::ostringstream os; os << snapCtrl.numBase << "-" << numIts; Write( estMap, os.str(), snapCtrl.numFormat ); if( snapCtrl.itCounts ) Write( itCountMap, os.str()+"-counts", snapCtrl.numFormat ); snapCtrl.numSaveCount = 0; } if( imgSave || imgDisp ) EntrywiseMap( estMap, []( Real alpha ) { return Log(alpha); } ); if( imgSave ) { std::ostringstream os; os << snapCtrl.imgBase << "-" << numIts; Write( estMap, os.str(), snapCtrl.imgFormat ); if( snapCtrl.itCounts ) Write( itCountMap, os.str()+"-counts", snapCtrl.imgFormat ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Write( estMap, os.str()+"-discrete", snapCtrl.imgFormat ); SetColorMap( colorMap ); snapCtrl.imgSaveCount = 0; } if( imgDisp ) { std::ostringstream os; os << snapCtrl.imgBase << "-" << numIts; Display( estMap, os.str() ); if( snapCtrl.itCounts ) Display( itCountMap, os.str()+"-counts" ); auto colorMap = GetColorMap(); SetColorMap( GRAYSCALE_DISCRETE ); Display( estMap, os.str()+"-discrete" ); SetColorMap( colorMap ); snapCtrl.imgDispCount = 0; } } }