Changeset 988 for GTP/trunk/Lib/Geom/shared/GeoTool/src
- Timestamp:
- 05/26/06 09:12:36 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r985 r988 952 952 { 953 953 // Simplify the mesh object. 954 simplifyEdgeCollapse(); 955 956 delete mMeshSimplifier; 957 geoMeshView->restoreContext(); 954 if(simplifyEdgeCollapse()) 955 { 956 delete mMeshSimplifier; 957 geoMeshView->restoreContext(); 958 } 958 959 } 959 960 break; … … 1004 1005 1005 1006 // Simplify the mesh object. 1006 simplifyEdgeCollapse(); 1007 1008 // Create the simplification sequence. 1009 createSimplificationSequence(); 1007 if (simplifyEdgeCollapse()) 1008 { 1009 // Create the simplification sequence. 1010 createSimplificationSequence(); 1011 } 1010 1012 1011 1013 } … … 1041 1043 mGeoMesh = mesh_aux; 1042 1044 1045 // Visualize mesh. 1046 geoMeshView->setMesh(mGeoMesh); 1047 1043 1048 // Simplify the mesh object. 1044 simplifyEdgeCollapse(); 1045 1046 // Create the simplification sequence. 1047 createSimplificationSequence(); 1048 1049 delete mMeshSimplifier; 1050 geoMeshView->restoreContext(); 1049 if (simplifyEdgeCollapse()) 1050 { 1051 // Create the simplification sequence. 1052 createSimplificationSequence(); 1053 1054 delete mMeshSimplifier; 1055 geoMeshView->restoreContext(); 1056 } 1051 1057 } 1052 1058 … … 1905 1911 // Simplify the mesh object. 1906 1912 //--------------------------------------------------------------------------- 1907 void GeoMeshViewUI::simplifyEdgeCollapse() 1908 { 1909 Real percent; 1910 1911 //----------------- 1912 geoMeshView->saveContext(); 1913 1914 // Gets simplify option. 1915 if (mGeometryBased->value()) 1916 { 1917 simplificationState = MESHSIMP; 1918 mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, 1919 progress_function); 1920 } 1921 else 1922 { 1923 simplificationState = VIEWPOINTDRIVEN; 1924 mMeshSimplifier = new ViewPointDrivenSimplifier(mGeoMesh, 1925 progress_function); 1926 } 1927 1928 mMeshSimplifier->setMeshLeaves(idMeshLeaves); 1929 1930 if (mPercent->value()) 1931 { 1932 // Simplificación por porcentaje 1933 if (mMeshReduction->fvalue() <= 100.0 && mMeshReduction->fvalue()>0.0) 1934 { 1935 percent = mMeshReduction->fvalue(); 1936 percent = percent / 100.0; 1937 1938 1939 // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. 1940 mMeshSimplifier->Simplify(percent); 1941 1942 // Deletes the previous mesh. 1943 delete mUndoMesh; 1944 1945 mUndoMesh = new Mesh(); 1946 1947 // Sets the undo mesh. 1948 *mUndoMesh = *mGeoMesh; 1949 1950 delete mGeoMesh; 1951 1952 mGeoMesh = mMeshSimplifier->GetMesh(); 1953 1954 // Visualize mesh. 1955 geoMeshView->setMesh(mGeoMesh); 1956 1957 } 1958 else 1959 { 1960 fltk::alert("Wrong value for simplification.\n" 1961 "Valid values [0..100]"); 1962 } 1963 } 1964 else 1965 { 1966 // Simplificar hasta un número de vértices. 1967 uint32 v = (uint32)mMeshReduction->fvalue(); 1968 1969 // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. 1970 mMeshSimplifier->Simplify(v); 1971 1972 // Deletes the previous mesh. 1973 delete mUndoMesh; 1974 1975 mUndoMesh = new Mesh(); 1976 1977 // Sets the undo mesh. 1978 *mUndoMesh = *mGeoMesh; 1979 1980 delete mGeoMesh; 1981 1982 mGeoMesh = mMeshSimplifier->GetMesh(); 1983 1984 // Visualize the mesh. 1985 geoMeshView->setMesh(mGeoMesh); 1986 } 1987 } 1913 bool GeoMeshViewUI::simplifyEdgeCollapse() 1914 { 1915 Real percent; 1916 1917 // If input field empty. 1918 if (mMeshReduction->fvalue() <= 0.0) 1919 { 1920 return false; 1921 } 1922 1923 geoMeshView->saveContext(); 1924 1925 // Debug. 1926 cout << "Mesh Reduction: " 1927 << mMeshReduction->fvalue() 1928 << endl; 1929 1930 // Gets simplify option. 1931 if (mGeometryBased->value()) 1932 { 1933 simplificationState = MESHSIMP; 1934 mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, 1935 1936 progress_function); 1937 } 1938 else 1939 { 1940 simplificationState = VIEWPOINTDRIVEN; 1941 mMeshSimplifier = new ViewPointDrivenSimplifier(mGeoMesh, 1942 1943 progress_function); 1944 } 1945 1946 mMeshSimplifier->setMeshLeaves(idMeshLeaves); 1947 1948 if (mPercent->value()) 1949 { 1950 // Simplificación por porcentaje 1951 if (mMeshReduction->fvalue() <= 100.0 && 1952 mMeshReduction->fvalue() > 0.0) 1953 { 1954 percent = mMeshReduction->fvalue(); 1955 percent = percent / 100.0; 1956 1957 // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. 1958 mMeshSimplifier->Simplify(percent); 1959 1960 // Deletes the previous mesh. 1961 delete mUndoMesh; 1962 1963 mUndoMesh = new Mesh(); 1964 1965 // Sets the undo mesh. 1966 *mUndoMesh = *mGeoMesh; 1967 1968 delete mGeoMesh; 1969 1970 mGeoMesh = mMeshSimplifier->GetMesh(); 1971 1972 // Visualize mesh. 1973 geoMeshView->setMesh(mGeoMesh); 1974 1975 } 1976 else 1977 { 1978 fltk::alert("Wrong value for simplification.\n" 1979 "Valid values [0..100]"); 1980 1981 return false; 1982 } 1983 } 1984 else 1985 { 1986 // Simplificar hasta un número de vértices. 1987 uint32 v = (uint32)mMeshReduction->fvalue(); 1988 1989 // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. 1990 mMeshSimplifier->Simplify(v); 1991 1992 // Deletes the previous mesh. 1993 delete mUndoMesh; 1994 1995 mUndoMesh = new Mesh(); 1996 1997 // Sets the undo mesh. 1998 *mUndoMesh = *mGeoMesh; 1999 2000 delete mGeoMesh; 2001 2002 mGeoMesh = mMeshSimplifier->GetMesh(); 2003 2004 // Visualize the mesh. 2005 geoMeshView->setMesh(mGeoMesh); 2006 } 2007 2008 return true; 2009 } 2010 1988 2011 1989 2012 //--------------------------------------------------------------------------- … … 2060 2083 secsimpl->Save(Geometry::Serializer("SimplifSequence.txt",Serializer::WRITE)); 2061 2084 2062 delete secsimpl;2085 //delete secsimpl; 2063 2086 } 2064 2087
Note: See TracChangeset
for help on using the changeset viewer.