[mapguide-commits] r4521 - trunk/MgDev/Common/Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jan 12 11:43:51 EST 2010


Author: traianstanev
Date: 2010-01-12 11:43:47 -0500 (Tue, 12 Jan 2010)
New Revision: 4521

Modified:
   trunk/MgDev/Common/Stylization/LineBuffer.cpp
   trunk/MgDev/Common/Stylization/LineBuffer.h
Log:
Ticket 1240: LineBuffer code cleanup. Added some "const" and made some members protected instead of private.

Modified: trunk/MgDev/Common/Stylization/LineBuffer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LineBuffer.cpp	2010-01-11 07:40:00 UTC (rev 4520)
+++ trunk/MgDev/Common/Stylization/LineBuffer.cpp	2010-01-12 16:43:47 UTC (rev 4521)
@@ -2037,7 +2037,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 
-void LineBuffer::Centroid(GeomOperationType type, double* x, double* y, double* slope)
+void LineBuffer::Centroid(GeomOperationType type, double* x, double* y, double* slope) const
 {
     switch (type)
     {
@@ -2058,7 +2058,7 @@
 }
 
 
-void LineBuffer::PolygonCentroid(int cntr, double* cx, double* cy)
+void LineBuffer::PolygonCentroid(int cntr, double* cx, double* cy) const
 {
     // for polygons, we just consider the outer ring and ignore any holes
 
@@ -2105,7 +2105,7 @@
 }
 
 
-void LineBuffer::PolygonCentroidTAW(int cntr, double* cx, double* cy)
+void LineBuffer::PolygonCentroidTAW(int cntr, double* cx, double* cy) const
 {
     double x1, x2, y1, y2, xt1(0.0), xt2(0.0), yt1(0.0), yt2(0.0);
     const int dpv = 3;  // triplets
@@ -2147,7 +2147,7 @@
 }
 
 
-void LineBuffer::PolygonCentroidBVM(int cntr, double* cx, double* cy)
+void LineBuffer::PolygonCentroidBVM(int cntr, double* cx, double* cy) const
 {
     const int dpv = 3;  // triplets
     double* pts = m_pts[contour_start_point(cntr)];
@@ -2169,7 +2169,7 @@
 }
 
 
-void LineBuffer::PolygonCentroidWMC(int cntr, double* cx, double* cy)
+void LineBuffer::PolygonCentroidWMC(int cntr, double* cx, double* cy) const
 {
     const int dpv = 3;  // triplets
     double* pts = m_pts[contour_start_point(cntr)];
@@ -2202,7 +2202,7 @@
 
 
 // computes the length of a polyline
-double LineBuffer::PolylineLength(int cntr)
+double LineBuffer::PolylineLength(int cntr) const
 {
     // pointer arithmetic looks ugly, and can be difficult to follow
     // but it produces tighter asm and this routine is called a lot
@@ -2230,7 +2230,7 @@
 
 // computes the squared length of a polyline - fast for relative length testing
 // same algorithm as PolylineLength without sqrt call
-double LineBuffer::PolylineLengthSqr(int cntr)
+double LineBuffer::PolylineLengthSqr(int cntr) const
 {
     // pointer arithmetic looks ugly, and can be difficult to follow
     // but it produces tighter asm and this routine is called a lot
@@ -2256,7 +2256,7 @@
 }
 
 
-double LineBuffer::PolygonArea(int cntr)
+double LineBuffer::PolygonArea(int cntr) const
 {
     // pointer arithmetic looks ugly, and can be difficult to follow
     // but it produces tighter asm and this routine is called a lot
@@ -2284,7 +2284,7 @@
 }
 
 
-void LineBuffer::MultiPolygonCentroid(double* cx, double* cy)
+void LineBuffer::MultiPolygonCentroid(double* cx, double* cy) const
 {
     // Computes the centroid of a MultiPolygon.  This is defined to
     // be the centroid of the largest polygon (polygon whose outer
@@ -2319,7 +2319,7 @@
 }
 
 
-void LineBuffer::MultiPolylineCentroid(double* cx, double* cy, double* slope)
+void LineBuffer::MultiPolylineCentroid(double* cx, double* cy, double* slope) const
 {
     // Computes the centroid of a MultiPolyline.  This is defined to
     // be the centroid of the longest polyline.
@@ -2355,7 +2355,7 @@
 }
 
 
-void LineBuffer::PolylineCentroid(int cntr, double* cx, double* cy, double* slope)
+void LineBuffer::PolylineCentroid(int cntr, double* cx, double* cy, double* slope) const
 {
     if ((m_cur_cntr < cntr) || (0 == m_cntrs[cntr]))
     {
@@ -2405,7 +2405,7 @@
 }
 
 
-void LineBuffer::MultiPointCentroid(double* cx, double* cy)
+void LineBuffer::MultiPointCentroid(double* cx, double* cy) const
 {
     int len = point_count();
     if (len == 0)
@@ -2435,7 +2435,7 @@
 
 
 // point in specific contour
-bool LineBuffer::PointInPolygon(int contour, double& x, double& y)
+bool LineBuffer::PointInPolygon(int contour, double& x, double& y) const
 {
     if (m_cur_cntr < contour)
     {
@@ -2500,7 +2500,7 @@
 
 
 // even-odd test for point containment
-bool LineBuffer::PointInPolygon(double& x, double& y)
+bool LineBuffer::PointInPolygon(double& x, double& y) const
 {
     bool ret = false;
 

Modified: trunk/MgDev/Common/Stylization/LineBuffer.h
===================================================================
--- trunk/MgDev/Common/Stylization/LineBuffer.h	2010-01-11 07:40:00 UTC (rev 4520)
+++ trunk/MgDev/Common/Stylization/LineBuffer.h	2010-01-12 16:43:47 UTC (rev 4521)
@@ -117,7 +117,7 @@
     // the cool stuff
     STYLIZATION_API LineBuffer* Optimize(double drawingScale, LineBufferPool* lbp);
     STYLIZATION_API LineBuffer* Clip(RS_Bounds& b, GeomOperationType clipType, LineBufferPool* lbp);
-    STYLIZATION_API void Centroid(GeomOperationType type, double* x, double * y, double* slope);
+    STYLIZATION_API void Centroid(GeomOperationType type, double* x, double * y, double* slope) const;
 
     // clears the buffer for reuse
     STYLIZATION_API void Reset(FdoDimensionality dimensionality = FdoDimensionality_XY, bool bIgnoreZ = true);
@@ -135,7 +135,7 @@
     STYLIZATION_API void NewGeometry();
 
     // checks for a point in any contour
-    STYLIZATION_API bool PointInPolygon(double& x, double& y);
+    STYLIZATION_API bool PointInPolygon(double& x, double& y) const;
 
     // sets the drawing scale (used for arc tessellation)
     STYLIZATION_API void SetDrawingScale(double drawingScale);
@@ -187,7 +187,7 @@
     inline void increment_contour();
     inline void increment_contour_pts();
 
-private:
+protected:
     unsigned char* m_types;     // segment types array (SegType)
     double (*m_pts)[3];         // raw point arry - triplets x, y, z
     int* m_cntrs;               // contour array
@@ -232,18 +232,18 @@
     static void AppendLBClipVertex(RS_Bounds& clipRect, double x, double y, LineBuffer* lb, bool move);
     void FinalizeContour();
 
-    void PolygonCentroid(int cntr, double* cx, double* cy); // centroid of specific contour
-    void PolygonCentroidTAW(int cntr, double* cx, double* cy);
-    void PolygonCentroidBVM(int cntr, double* cx, double* cy);
-    void PolygonCentroidWMC(int cntr, double* cx, double* cy);
-    void PolylineCentroid(int cntr, double* cx, double* cy, double* slope);
-    void MultiPointCentroid(double* cx, double* cy);
-    void MultiPolygonCentroid(double* cx, double* cy);
-    void MultiPolylineCentroid(double* cx, double* cy, double* slope);
-    bool PointInPolygon(int cntr, double& x, double& y); // point in specific contour
-    double PolygonArea(int cntr);
-    double PolylineLength(int cntr);
-    double PolylineLengthSqr(int cntr);
+    void PolygonCentroid(int cntr, double* cx, double* cy) const; // centroid of specific contour
+    void PolygonCentroidTAW(int cntr, double* cx, double* cy) const;
+    void PolygonCentroidBVM(int cntr, double* cx, double* cy) const;
+    void PolygonCentroidWMC(int cntr, double* cx, double* cy) const;
+    void PolylineCentroid(int cntr, double* cx, double* cy, double* slope) const;
+    void MultiPointCentroid(double* cx, double* cy) const;
+    void MultiPolygonCentroid(double* cx, double* cy) const;
+    void MultiPolylineCentroid(double* cx, double* cy, double* slope) const;
+    bool PointInPolygon(int cntr, double& x, double& y) const; // point in specific contour
+    double PolygonArea(int cntr) const;
+    double PolylineLength(int cntr) const;
+    double PolylineLengthSqr(int cntr) const;
 
     void ResizePoints(int n);    // new size of array # of points
     void ResizeContours(int n);



More information about the mapguide-commits mailing list