[mapguide-commits] r4524 - sandbox/adsk/2.2gp/Common/Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jan 12 17:16:05 EST 2010


Author: traianstanev
Date: 2010-01-12 17:16:05 -0500 (Tue, 12 Jan 2010)
New Revision: 4524

Modified:
   sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.cpp
   sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.h
Log:
Carry over changes from Ticket 1240 from trunk to branch.

Modified: sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.cpp
===================================================================
--- sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.cpp	2010-01-12 20:45:35 UTC (rev 4523)
+++ sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.cpp	2010-01-12 22:16:05 UTC (rev 4524)
@@ -1203,13 +1203,24 @@
             int num_geoms = m_cur_geom + 1;
             if (is_multi)
             {
-                //write number of geometries
-                WRITE_INT(os, num_geoms);
+                if (m_geom_type == FdoGeometryType_MultiPoint)
+                {
+                    //write number of geometries -- for multipoint the
+                    //number of contours (i.e. MoveTos) is equal to the
+                    //number of point geometries in the multipoint
+                    WRITE_INT(os, m_num_geomcntrs[0]);
+                    num_geoms = m_num_geomcntrs[0];
+                }
+                else
+                {
+                    //write number of geometries
+                    WRITE_INT(os, num_geoms);
+                }
             }
 
             for (int q=0; q<num_geoms; ++q)
             {
-                // skip past geometry type of subgeometry
+                // write geometry type of subgeometry
                 // we know it is LineString or Polygon or Point respectively
                 if (is_multi)
                 {
@@ -1244,7 +1255,7 @@
                 int contour_count = 1; //for linestrings
 
                 if (m_geom_type == FdoGeometryType_MultiPolygon ||
-                    m_geom_type == FdoGeometryType_Polygon)
+                    m_geom_type == FdoGeometryType_Polygon )
                 {
                     contour_count = m_num_geomcntrs[q];
                     WRITE_INT(os, contour_count);
@@ -2037,7 +2048,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 +2069,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 +2116,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 +2158,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 +2180,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 +2213,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 +2241,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 +2267,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 +2295,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 +2330,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 +2366,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 +2416,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 +2446,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 +2511,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: sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.h
===================================================================
--- sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.h	2010-01-12 20:45:35 UTC (rev 4523)
+++ sandbox/adsk/2.2gp/Common/Stylization/LineBuffer.h	2010-01-12 22:16:05 UTC (rev 4524)
@@ -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,11 +135,16 @@
     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;
+    STYLIZATION_API bool PointInPolygon(int cntr, double& x, double& y) const; // point in specific contour
 
     // sets the drawing scale (used for arc tessellation)
     STYLIZATION_API void SetDrawingScale(double drawingScale);
 
+    STYLIZATION_API double PolygonArea(int cntr) const;
+    STYLIZATION_API double PolylineLength(int cntr) const;
+    STYLIZATION_API double PolylineLengthSqr(int cntr) const;
+
     // the inline stuff
     inline unsigned char point_type(int n) const;
     inline int point_count() const;         // number of points in buffer
@@ -187,7 +192,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 +237,15 @@
     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;
+    
 
     void ResizePoints(int n);    // new size of array # of points
     void ResizeContours(int n);



More information about the mapguide-commits mailing list