void CSG_Doc_SVG::Draw_Rectangle(double xa, double ya, double xb, double yb, int Fill_Color, int Line_Color, double Line_Width) { CSG_Points Points; Points.Add(xa, ya); Points.Add(xb, ya); Points.Add(xb, yb); Points.Add(xa, yb); Draw_Polygon(Points, Fill_Color, Line_Color, Line_Width); }
//--------------------------------------------------------- bool CAtlas_BNA_Export::On_Execute(void) { int iShape, iPart, iPoint, iName1, iName2; FILE *Stream; TSG_Point p; CSG_Points Pts; CSG_Shape *pShape; CSG_Shapes *pShapes; CSG_String fName; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); fName = Parameters("FILE") ->asString(); iName1 = Parameters("PNAME") ->asInt(); iName2 = Parameters("SNAME") ->asInt(); //----------------------------------------------------- if( (Stream = fopen(fName.b_str(), "w")) != NULL ) { for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { pShape = pShapes->Get_Shape(iShape); switch( pShapes->Get_Type() ) { default: break; //--------------------------------------------- case SHAPE_TYPE_Point: fprintf(Stream, "\"%s\",\"%s\",%d\n", pShape->asString(iName1), pShape->asString(iName2), 1 ); p = pShape->Get_Point(0); fprintf(Stream, "%f,%f\n", p.x, p.y); break; //--------------------------------------------- case SHAPE_TYPE_Line: for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++) { fprintf(Stream, "\"%s\",\"%s\",%d\n", pShape->asString(iName1), pShape->asString(iName2), -pShape->Get_Point_Count(iPart) ); for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++) { p = pShape->Get_Point(iPoint, iPart); fprintf(Stream, "%f,%f\n", p.x, p.y); } } break; //--------------------------------------------- case SHAPE_TYPE_Polygon: if( pShape->Get_Part_Count() > 0 && pShape->Get_Point_Count(0) > 2 ) { Pts.Clear(); for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++) { for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++) { Pts.Add(pShape->Get_Point(iPoint, iPart)); } if( iPart > 0 ) { Pts.Add(pShape->Get_Point(0, 0)); } } if( Pts.Get_Count() > 2 ) { fprintf(Stream, "\"%s\",\"%s\",%d\n", pShape->asString(iName1), pShape->asString(iName2), Pts.Get_Count() ); for(iPoint=0; iPoint<Pts.Get_Count(); iPoint++) { fprintf(Stream, "%f,%f\n", Pts[iPoint].x, Pts[iPoint].y); } } } break; } } fclose(Stream); return( true ); } //----------------------------------------------------- return( false ); }