diff options
| author | Kris De Gussem <kris.degussem@gmail.com> | 2012-02-15 07:25:29 +0000 |
|---|---|---|
| committer | Kris <Kris.De.Gussem@hotmail.com> | 2012-02-15 07:25:29 +0000 |
| commit | 8edcffdc305b2c09a4f9b886fee12ecfc48a0e24 (patch) | |
| tree | 2365a85f9cae27fb1f8053ff69f445b02304c12e /src/extension/dxf2svg | |
| parent | Snap to grid/guide lines perpendicularly (diff) | |
| download | inkscape-8edcffdc305b2c09a4f9b886fee12ecfc48a0e24.tar.gz inkscape-8edcffdc305b2c09a4f9b886fee12ecfc48a0e24.zip | |
cppcheck
(bzr r10977)
Diffstat (limited to 'src/extension/dxf2svg')
| -rw-r--r-- | src/extension/dxf2svg/dxf2svg.cpp | 15 | ||||
| -rw-r--r-- | src/extension/dxf2svg/entities.cpp | 16 | ||||
| -rw-r--r-- | src/extension/dxf2svg/entities2elements.cpp | 15 |
3 files changed, 9 insertions, 37 deletions
diff --git a/src/extension/dxf2svg/dxf2svg.cpp b/src/extension/dxf2svg/dxf2svg.cpp index ce2419a95..4884ed3fe 100644 --- a/src/extension/dxf2svg/dxf2svg.cpp +++ b/src/extension/dxf2svg/dxf2svg.cpp @@ -18,15 +18,8 @@ #include"entities2elements.h" - - - - - - int main(int argc,char *argv[]){ // Later include options for different conversions like converting as much as possible into paths - int ink = 1; // Assume for now there is no inkscape stuff to add extra if(argc > 1){ double scaling = 90; // converstion from in to pt @@ -64,13 +57,14 @@ int main(int argc,char *argv[]){ char units[5] = "in"; char tmp_char[100000]; char layer_string[500]; + // int ink = 1; // Assume for now there is no inkscape stuff to add extra - if (ink < 1){ + /*if (ink < 1){ // Write a general svg header std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n\t\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\"\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; std::cout << "\tx=\"0.00000000\"\n\ty=\"0.00000000\"\n\twidth=\"744.09448\"\n\theight=\"-1052.3622\"" << std::endl; } - else{ + else{*/ std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << std::endl; std::cout << "<!-- Created with dxf2svg -->" << std::endl; std::cout << "<svg" << std::endl; @@ -82,8 +76,7 @@ int main(int argc,char *argv[]){ std::cout << "\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" << std::endl; std::cout << "\txmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" << std::endl; std::cout << "\t>" << std::endl; - - } + //} // Now write SVG elements to file diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp index c94df06f3..0b18ab176 100644 --- a/src/extension/dxf2svg/entities.cpp +++ b/src/extension/dxf2svg/entities.cpp @@ -278,14 +278,10 @@ double polyline::bulge_start_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi @@ -307,14 +303,10 @@ double polyline::bulge_end_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point+1].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi @@ -473,14 +465,10 @@ double lwpolyline::bulge_start_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi @@ -502,14 +490,10 @@ double lwpolyline::bulge_end_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point+1].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi diff --git a/src/extension/dxf2svg/entities2elements.cpp b/src/extension/dxf2svg/entities2elements.cpp index f280bb2a8..8a17a0d84 100644 --- a/src/extension/dxf2svg/entities2elements.cpp +++ b/src/extension/dxf2svg/entities2elements.cpp @@ -60,7 +60,6 @@ char* to_arc(double bulge, double r, double start_ang, double end_ang, int preci } // Build Coordinate -void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out); // Pairs of coords with units will be used so often build a function void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out){ // Pairs of coords with units will be used so often build a function build a dedicated function for returning such @@ -75,7 +74,7 @@ void coord(entity *ent, int precision,char* delim, char * units, double scaling, } // DXF Polyline -> SVG -void pline2svg(polyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out); // General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported +// General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported void pline2svg(polyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){ // 0 is pline2path // 1 is pline2pline @@ -83,8 +82,6 @@ void pline2svg(polyline pline, int type, int precision, char * units, double sca char delim[2]; - double mag_bulge = 0; - double prev_mag_bulge = 0; std::vector< vertex >::iterator vver_iter; std::vector< vertex > points = pline.ret_points(); @@ -94,7 +91,7 @@ void pline2svg(polyline pline, int type, int precision, char * units, double sca strcpy(delim," "); strcat(out, "M "); coord( &points[0], precision, delim, units, scaling, out ); - prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude + double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude if ( prev_mag_bulge > pow(0.1,precision) ){ to_arc(pline.bulge(0), pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, units, scaling, out); } @@ -105,7 +102,7 @@ void pline2svg(polyline pline, int type, int precision, char * units, double sca } coord( &points[i], precision, delim, units, scaling, out ); // If bulge > some precsion then add bulge - mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); + double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); if ( (mag_bulge > pow(0.1,precision)) && (i < (points.size() - 1) )){ to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); } @@ -188,8 +185,6 @@ void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double char delim[2]; - double mag_bulge = 0; - double prev_mag_bulge = 0; std::vector< vertex >::iterator vver_iter; std::vector< vertex > points = pline.ret_points(); @@ -199,7 +194,7 @@ void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double strcpy(delim," "); strcat(out, "M "); coord( &points[0], precision, delim, NULL, scaling, out ); - prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude + double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude if ( prev_mag_bulge > pow(0.1,precision) ){ to_arc(pline.bulge(0),pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, NULL, scaling, out); } @@ -211,7 +206,7 @@ void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double } coord( &points[i], precision, delim, NULL , scaling, out ); // If bulge > some precsion then add bulge - mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); + double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); if ( ( mag_bulge > pow(0.1,precision) ) && (i < (points.size() - 1) )){ // Make sure the final point doesn't add a bulge on accident to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); } |
