[Kstars-devel] KDE/kdeedu/kstars/kstars
James Bowlin
bowlin at mindspring.com
Thu Aug 16 07:12:27 CEST 2007
SVN commit 700649 by jbowlin:
Changed the mesh level from 5 to 4. This seemed to speed things up
when the screen was zoomed out. You are encouraged to try different
mesh levels yourself. You can change it in skymapcomposite.cpp on
line 55. I don't recommend using levels greater than 6.
FYI:
level # of trixels
----- ------------
2 128
3 512
4 2,048
5 8,192
6 32,768
Added 4 new data files that contain pre-computed indices for the
constellations. This greatly speeds up the constellation boundary
initialization. If the index file does not exist, we fall back
to computing the indices. There is a separate index file for
mesh levels 3 through 6. There is also a mechanism for creating
the data files in ConstellationBoundaryLines::init() by setting
verbose to -1. This will cause the indices to be computed and
printed on stdout.
CCMAIL: kstars-devel at kde.org
M +1 -0 data/CMakeLists.txt
A data/cbounds-3.idx
A data/cbounds-4.idx
A data/cbounds-5.idx
A data/cbounds-6.idx
M +4 -0 htmesh/HTMesh.h
M +17 -11 skycomponents/constellationboundarylines.cpp
M +30 -3 skycomponents/polylistindex.cpp
M +7 -0 skycomponents/polylistindex.h
M +1 -1 skycomponents/skymapcomposite.cpp
--- trunk/KDE/kdeedu/kstars/kstars/data/CMakeLists.txt #700648:700649
@@ -8,6 +8,7 @@
cnames.dat
milkyway.dat
cbounds.dat
+ cbounds-3.idx cbounds-4.idx cbounds-5.idx cbounds-6.idx
image_url.dat info_url.dat
mercury.L0.vsop mercury.L1.vsop mercury.L2.vsop mercury.L3.vsop
mercury.L4.vsop mercury.L5.vsop mercury.B0.vsop mercury.B1.vsop
--- trunk/KDE/kdeedu/kstars/kstars/htmesh/HTMesh.h #700648:700649
@@ -126,6 +126,10 @@
*/
int size() const { return numTrixels; }
+ /* @short returns the mesh level.
+ */
+ int level() const { return m_level; }
+
/* @short sets the debug level which is used to print out intermediate
* results in the line intersection routine.
*/
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/constellationboundarylines.cpp #700648:700649
@@ -62,6 +62,8 @@
void ConstellationBoundaryLines::init( KStarsData *data ) {
+ int verbose = 0; // -1 => create cbounds-$x.idx on stdout
+ // 0 => normal
char* fname = "cbounds.dat";
int flag;
double ra, dec, lastRa, lastDec;
@@ -73,11 +75,20 @@
intro();
+ // Open the .idx file and skip past the first line
+ KSFileReader idxReader, *idxFile = 0;
+ QString idxFname = QString("cbounds-%1.idx").arg( SkyMesh::Instance()->level() );
+ if ( idxReader.open( idxFname ) ) {
+ idxReader.readLine();
+ idxFile = &idxReader;
+ }
+
+ // now open the file that contains the points
KSFileReader fileReader;
if ( ! fileReader.open( fname ) ) return;
fileReader.setProgress( data,
- i18n("Loading Consellation Boundaries"), 13124, 20, 100 );
+ i18n("Loading Consellation Boundaries"), 13124, 5, 100 );
lastRa = lastDec = -1000.0;
@@ -86,17 +97,15 @@
fileReader.showProgress();
if ( line.at( 0 ) == '#' ) continue; // ignore comments
- if ( line.at( 0 ) == ':' ) { // :NAM line
+ if ( line.at( 0 ) == ':' ) { // :constellation line
if ( lineList ) appendLine( lineList );
- lineList = 0; //new LineList();
+ lineList = 0;
- if ( polyList ) boundaryPoly->appendPoly( polyList );
+ if ( polyList ) boundaryPoly->appendPoly( polyList, idxFile, verbose );
QString cName = line.mid(1, 3);
polyList = new PolyList( cName );
-
- //kDebug() << QString(":%1\n").arg( polyList->name() );
-
+ if ( verbose == -1 ) printf(":\n");
continue;
}
@@ -110,8 +119,6 @@
continue;
}
- //fprintf(stderr, "%12.7f %12.7f %d\n", ra, dec, flag);
-
if ( ra == lastRa && dec == lastDec ) {
fprintf(stderr, "%s: tossing dupe on line %4d: (%f, %f)\n",
fname, fileReader.lineNumber(), ra, dec);
@@ -140,11 +147,10 @@
}
if ( lineList ) appendLine( lineList );
- if ( polyList ) boundaryPoly->appendPoly( polyList );
+ if ( polyList ) boundaryPoly->appendPoly( polyList, idxFile, verbose );
summary();
boundaryPoly->summary();
-
}
bool ConstellationBoundaryLines::selected()
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/polylistindex.cpp #700648:700649
@@ -26,6 +26,7 @@
#include "kstarsdata.h"
#include "ksutils.h"
#include "skyobject.h"
+#include "ksfilereader.h"
#include "polylist.h"
#include "polylistindex.h"
@@ -42,16 +43,35 @@
}
}
+void PolyListIndex::appendPoly( PolyList* polyList, KSFileReader* file, int debug)
+{
+ if ( ! file || debug == -1)
+ return appendPoly( polyList, debug );
+
+ m_nameHash.insert( polyList->name(), polyList );
+
+ while ( file->hasMoreLines() ) {
+ QString line = file->readLine();
+ if ( line.at( 0 ) == ':' ) return;
+ Trixel trixel = line.toInt();
+ m_polyIndex[ trixel ]->append( polyList );
+ }
+}
+
void PolyListIndex::appendPoly( PolyList* polyList, int debug)
{
m_nameHash.insert( polyList->name(), polyList );
- if ( debug < skyMesh()->debug() ) debug = skyMesh()->debug();
+ if ( debug >= 0 && debug < skyMesh()->debug() ) debug = skyMesh()->debug();
const IndexHash& indexHash = skyMesh()->indexPoly( polyList->poly() );
+ IndexHash::const_iterator iter = indexHash.constBegin();
+ while ( iter != indexHash.constEnd() ) {
+ Trixel trixel = iter.key();
+ iter++;
- foreach (Trixel trixel, indexHash.keys()) { // foreach okay because we
- // we needed a copy anyway
+ if ( debug == -1 ) printf("%d\n", trixel );
+
m_polyIndex[ trixel ]->append( polyList );
}
@@ -67,6 +87,13 @@
int total = skyMesh()->size();
int polySize = m_polyIndex.size();
+ /**
+ for ( int i = 0; i < polySize; i++ ) {
+ PolyListList* listList = m_polyIndex.at( i );
+ printf("%4d: %d\n", i, listList->size() );
+ }
+ **/
+
if ( polySize > 0 )
printf("%4d out of %4d trixels in poly index %3d%%\n",
polySize, total, 100 * polySize / total );
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/polylistindex.h #700648:700649
@@ -24,6 +24,7 @@
#include <QPolygonF>
class PolyList;
+class KSFileReader;
typedef QVector<PolyList*> PolyListList;
typedef QVector<PolyListList*> PolyIndex;
@@ -47,6 +48,12 @@
void appendPoly( PolyList* polyList, int debug=0);
+ /* @short reads the indices from the KSFileReader instead of using
+ * the SkyMesh to create them. If the file pointer is null or if
+ * debug == -1 then we fall back to using the index.
+ */
+ void appendPoly( PolyList* polyList, KSFileReader* file, int debug);
+
SkyMesh* skyMesh() { return m_skyMesh; }
PolyList* ContainingPoly( SkyPoint *p );
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymapcomposite.cpp #700648:700649
@@ -52,7 +52,7 @@
{
m_skyLabeler = SkyLabeler::Instance();
- m_skyMesh = SkyMesh::Create( data, 5 ); // level 5 mesh = 8192 trixels
+ m_skyMesh = SkyMesh::Create( data, 4 ); // level 5 mesh = 8192 trixels
m_skyMesh->debug( 0 ); // 1 => print "indexing ..."
// 2 => prints totals too
More information about the Kstars-devel
mailing list