طلب مساعدة منأهل التخصص رجاء سريع

mohcine1983

  • Jr. Member
  • **
    • مشاركة: 63
    • مشاهدة الملف الشخصي
    • البريد الالكتروني
في: آب 26, 2012, 04:57:47 صباحاً
ارجو من أصحاب التخصص في مجال البرمجة في سي عندي des codes en C يحتاجون لبعض التعديل ارجو و عاجلا أن تساعدوني الأنني بعد في تعديلهم للأنني بعد دلك أحتاج لبرمجتهم    en parallèle sur GPU en  cuda  basé surِ c كل من اسأل يقول لي غير متخصص في CUDA
و لهدا أجلت التخرج حتى سبتمبر قد أتى ولم أفعل شيئا أرجوكم ساعدوني ولو بالقليل .
   il ya six codes label.h,layer.h, pal.h,palexception.h, palgeometry.h,palstat.h            

00001 /*
00002  *   libpal - Automated Placement of Labels Library     http://pal.heig-vd.ch
00003  *
00004  *
00005  *   Copyright (C) 2007, 2008 MIS-TIC, HEIG-VD (University of Applied Sciences Western Switzerland)
00006  *   Copyright (C) 2008, 2009 IICT-SYSIN, HEIG-VD (University of Applied Sciences Western Switzerland)
00007  *
00008  *
00009  * This file is part of libpal.
00010  *
00011  * libpal is free software: you can redistribute it and/or modify
00012  * it under the terms of the GNU Lesser General Public License as published by
00013  * the Free Software Foundation, either version 3 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * libpal is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with libpal. If not, see .
00023  *
00024  */
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include
00028 #endif
00029
00030 #ifndef _LABEL_H
00031 #define _LABEL_H
00032
00033 namespace pal {
00034
00035     class LabelPosition;
00036     class PalGeometry;
00037
00041     class Label {
00042
00043         friend class LabelPosition;
00044     private:
00045         double x[4];
00046         double y[4];
00047
00048         double a;
00049
00050         char *featureId;
00051         char *lyrName;
00052
00053         PalGeometry *userGeom;
00054
00065         Label (double x[4], double y[4], double alpha, const char *ftid, const char *lyrName, PalGeometry *userGeom);
00066
00067     public:
00071         ~Label();
00072
00077         double getOrigX();
00078
00083         double getOrigY();
00084
00090         double getX (size_t i);
00091
00097         double getY (size_t i);
00098
00103         double getRotation();
00104
00109         const char *getLayerName();
00110
00115         const char *getFeatureId();
00116
00121         PalGeometry * getGeometry();
00122     };
00123
00124 } // end namespace pal
00125
00126 #endif
programme2:layer.h
00001 /*
00002  *   libpal - Automated Placement of Labels Library     http://pal.heig-vd.ch
00003  *
00004  *
00005  *   Copyright (C) 2007, 2008 MIS-TIC, HEIG-VD (University of Applied Sciences Western Switzerland)
00006  *   Copyright (C) 2008, 2009 IICT-SYSIN, HEIG-VD (University of Applied Sciences Western Switzerland)
00007  *
00008  *
00009  * This file is part of libpal.
00010  *
00011  * libpal is free software: you can redistribute it and/or modify
00012  * it under the terms of the GNU Lesser General Public License as published by
00013  * the Free Software Foundation, either version 3 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * libpal is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with libpal. If not, see .
00023  *
00024  */
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include
00028 #endif
00029
00030 #ifndef _LAYER_H_
00031 #define _LAYER_H_
00032
00033 #include
00034
00035 #include
00036 #include
00037
00038
00039 namespace pal {
00040 //#include
00041
00042     template class LinkedList;
00043     template class Cell;
00044     template class HashTable;
00045
00046     template class RTree;
00047
00048     class Feature;
00049     class Pal;
00050     class SimpleMutex;
00051
00052     struct Feat;
00053
00061     class Layer {
00062         friend class Pal;
00063         friend class Feature;
00064
00065         friend class Problem;
00066
00067         friend class LabelPosition;
00068         friend bool extractFeatCallback (Feature *ft_ptr, void *ctx);
00069         friend bool pruneLabelPositionCallback (LabelPosition *lp, void *ctx);
00070         friend bool obstacleCallback (PointSet *feat, void *ctx);
00071         friend void toSVGPath (int nbPoints, double *x, double *y, int dpi, Layer *layer, int type, char *uid, std::ostream &out, double scale, Units unit, int xmin, int xmax, int ymax, bool exportInfo, char *color);
00072         friend bool filteringCallback (PointSet*, void*);
00073
00074     protected:
00075         char *name; /* unique */
00076
00077
00078         LinkedList *features;
00079
00080         Pal *pal;
00081
00082         double defaultPriority;
00083
00084         bool obstacle;
00085         bool active;
00086         bool toLabel;
00087
00088         Units label_unit;
00089
00090         double min_scale;
00091         double max_scale;
00092
00093         Arrangement arrangement;
00094
00095         // indexes (spatial and id)
00096         RTree *rtree;
00097         HashTable*> *hashtable;
00098
00099         SimpleMutex *modMutex;
00100
00116         Layer (const char *lyrName, double min_scale, double max_scale, Arrangement arrangement, Units label_unit, double defaultPriority, bool obstacle, bool active, bool toLabel, Pal *pal);
00117
00121         virtual ~Layer();
00122
00128         Cell *getFeatureIt (const char * geom_id);
00129
00134         bool isScaleValid (double scale);
00135
00136     public:
00140         int getNbFeatures();
00141
00145         const char * getName();
00146
00147
00152         void rename (char *name);
00153
00157         Arrangement getArrangement();
00158
00164         void setArrangement (Arrangement arrangement);
00165
00169         Units getLabelUnit ();
00170
00175         void setLabelUnit (Units label_unit);
00176
00186         void setActive (bool active);
00187
00191         bool isActive();
00192
00193
00201         void setToLabel (bool toLabel);
00202
00203
00207         bool isToLabel();
00208
00209
00217         void setObstacle (bool obstacle);
00218
00222         bool isObstacle();
00223
00229         void setMinScale (double min_scale);
00230
00234         double getMinScale();
00235
00236
00242         void setMaxScale (double max_scale);
00243
00244
00248         double getMaxScale();
00249
00250
00257         void setPriority (double priority);
00258
00259
00263         double getPriority();
00264
00275         void registerFeature (const char *geom_id, PalGeometry *userGeom, double label_x =-1, double label_y = -1);
00276
00277         // TODO implement
00278         //void unregisterFeature (const char *geom_id);
00279
00280         // TODO call that when a geometry change (a moveing points, etc)
00281         //void updateFeature();
00282
00293         void setFeatureLabelSize (const char *geom_id, double label_x, double label_y);
00294
00302         double getFeatureLabelHeight (const char *geom_id);
00303
00311         double getFeatureLabelWidth (const char *geom_id);
00312
00313
00323         void setFeatureDistlabel (const char *geom_id, int distlabel);
00324
00333         int getFeatureDistlabel (const char *geom_id);
00334
00335     };
00336
00337 } // end namespace pal
00338
00339 #endif

programme3:pal.h
00001 /*
00002  *   libpal - Automated Placement of Labels Library     http://pal.heig-vd.ch
00003  *
00004  *
00005  *   Copyright (C) 2007, 2008 MIS-TIC, HEIG-VD (University of Applied Sciences Western Switzerland)
00006  *   Copyright (C) 2008, 2009 IICT-SYSIN, HEIG-VD (University of Applied Sciences Western Switzerland)
00007  *
00008  *
00009  * This file is part of libpal.
00010  *
00011  * libpal is free software: you can redistribute it and/or modify
00012  * it under the terms of the GNU Lesser General Public License as published by
00013  * the Free Software Foundation, either version 3 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * libpal is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with libpal. If not, see .
00023  *
00024  */
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include
00028 #endif
00029
00030 #ifndef _PAL_H
00031 #define _PAL_H
00032
00033 #include
00034 #include
00035
00036 #include
00037 #include
00038 #include
00039
00040 // TODO ${MAJOR} ${MINOR} etc instead of 0.2
00041
00051 namespace pal {
00052
00053     template class LinkedList;
00054
00055     class Layer;
00056     class LabelPosition;
00057     class Problem;
00058     class PointSet;
00059     class SimpleMutex;
00060
00062     enum _Units {
00063         PIXEL = 0,
00064         METER,
00065         FOOT,
00066         DEGREE
00067     };
00068
00070     typedef enum _Units Units;
00071
00073     enum _searchMethod {
00074         CHAIN = 0,
00075         POPMUSIC_TABU_CHAIN = 1,
00076         POPMUSIC_TABU = 2,
00077         POPMUSIC_CHAIN = 3
00078     };
00079
00081     typedef enum _searchMethod SearchMethod;
00082
00087     enum _arrangement {
00088         P_POINT = 0,
00089         P_LINE,
00090         P_HORIZ,
00091         P_FREE,
00092         P_LINE_AROUND
00093     };
00094
00096     typedef enum _arrangement Arrangement;
00097
00098
00107     class Pal {
00108         friend class Problem;
00109         friend class Feature;
00110         friend class Layer;
00111         friend class LabelPosition;
00112         friend class PointSet;
00113         friend bool pruneLabelPositionCallback (LabelPosition *lp, void *ctx);
00114     private:
00115         std::list * layers;
00116
00117         SimpleMutex *lyrsMutex;
00118
00119         // TODO remove after tests !!!
00120         clock_t tmpTime;
00121
00122         Units map_unit;
00123
00127         int point_p;
00128
00132         int line_p;
00133
00137         int poly_p;
00138
00139         SearchMethod searchMethod;
00140
00141         /*
00142          * POPMUSIC Tuning
00143          */
00144         int popmusic_r;
00145
00146         int tabuMaxIt;
00147         int tabuMinIt;
00148
00149         int dpi;
00150
00151         int ejChainDeg;
00152         int tenure;
00153         double candListSize;
00154
00170         Problem* extract (int nbLayers, char **layersName, double *layersFactor,
00171                           double lambda_min, double phi_min,
00172                           double lambda_max, double phi_max,
00173                           double scale, std::ofstream *svgmap);
00174
00175
00180         void setPopmusicR (int r);
00181
00182
00183
00188         void setMinIt (int min_it);
00189
00194         void setMaxIt (int max_it);
00195
00200         void setTenure (int tenure);
00201
00206         void setEjChainDeg (int degree);
00207
00212         void setCandListSize (double fact);
00213
00214
00219         int getMinIt ();
00224         int getMaxIt ();
00225
00226
00227     public:
00228
00232         Pal();
00233
00237         ~Pal();
00238
00256         Layer * addLayer (const char *lyrName, double min_scale, double max_scale, Arrangement arrangement, Units label_unit, double defaultPriority, bool obstacle, bool active, bool toLabel);
00257
00267         Layer *getLayer (const char *lyrName);
00268
00274         std::list *getLayers ();
00275
00281         void removeLayer (Layer *layer);
00282
00294         std::list *labeller (double scale, double bbox[4], PalStat **stats, bool displayAll);
00295
00296
00314         std::list *labeller (int nbLayers,
00315                                      char **layersName,
00316                                      double *layersFactor,
00317                                      double scale, double bbox[4],
00318                                      PalStat **stat,
00319                                      bool displayAll);
00320
00326         void setDpi (int dpi);
00327
00333         int getDpi ();
00334
00335
00336
00343         void setPointP (int point_p);
00344
00351         void setLineP (int line_p);
00352
00359         void setPolyP (int poly_p);
00360
00364         int getPointP ();
00365
00369         int getLineP ();
00370
00374         int getPolyP ();
00375
00379         Units getMapUnit();
00380
00384         void setMapUnit(Units map_unit);
00385
00394         void setSearch (SearchMethod method);
00395
00401         SearchMethod getSearch();
00402     };
00403 } // end namespace pal
00404 #endif

programme4:palexception.h
00001 /*
00002  *   libpal - Automated Placement of Labels Library     http://pal.heig-vd.ch
00003  *
00004  *
00005  *   Copyright (C) 2007, 2008 MIS-TIC, HEIG-VD (University of Applied Sciences Western Switzerland)
00006  *   Copyright (C) 2008, 2009 IICT-SYSIN, HEIG-VD (University of Applied Sciences Western Switzerland)
00007  *
00008  *
00009  * This file is part of libpal.
00010  *
00011  * libpal is free software: you can redistribute it and/or modify
00012  * it under the terms of the GNU Lesser General Public License as published by
00013  * the Free Software Foundation, either version 3 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * libpal is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with libpal. If not, see .
00023  *
00024  */
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include
00028 #endif
00029
00030 #ifndef _EXCEPTION_H
00031 #define _EXCEPTION_H
00032
00033 #include
00034
00035
00036 namespace pal {
00037
00040     class PalException {
00041     public:
00042
00045         class NotImplemented : public std::exception {
00046             const char * what() const throw() {
00047                 return "Not yet implemented... sorry";
00048             }
00049         };
00050
00053         class UnknownFeature : public std::exception {
00054             const char * what() const throw() {
00055                 return "Feature not found";
00056             }
00057         };
00058
00061         class UnknownLayer : public std::exception {
00062             const char * what() const throw() {
00063                 return "Layer not found";
00064             }
00065         };
00066
00069         class LayerExists : public std::exception {
00070             const char * what() const throw() {
00071                 return "Layers names must be unique";
00072             }
00073         };
00074
00077         class FeatureExists : public std::exception {
00078             const char * what() const throw() {
00079                 return "Features IDs must be unique within a layer";
00080             }
00081         };
00082
00091         class ValueNotInRange : public std::exception {
00092             const char * what() const throw() {
00093                 return "value not allowed";
00094             }
00095         };
00096     };
00097
00098 } // namespace
00099
00100 #endif

programm5:palgeometry.h
00001 /*
00002  *   libpal - Automated Placement of Labels Library     http://pal.heig-vd.ch
00003  *
00004  *
00005  *   Copyright (C) 2007, 2008 MIS-TIC, HEIG-VD (University of Applied Sciences Western Switzerland)
00006  *   Copyright (C) 2008, 2009 IICT-SYSIN, HEIG-VD (University of Applied Sciences Western Switzerland)
00007  *
00008  *
00009  * This file is part of libpal.
00010  *
00011  * libpal is free software: you can redistribute it and/or modify
00012  * it under the terms of the GNU Lesser General Public License as published by
00013  * the Free Software Foundation, either version 3 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * libpal is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with libpal. If not, see .
00023  *
00024  */
00025
00026 #ifndef _PAL_GEOMETRY_H
00027 #define _PAL_GEOMETRY_H
00028
00029 #include
00030 #include
00031 #include
00032
00033 namespace pal {
00034
00038     class PalGeometry {
00039     public:
00040         /*
00041          * \brief get the geometry in WKB hexa format
00042          * This method is called by Pal each time it needs a geom's coordinates
00043          *
00044          * @return WKB Hex buffer
00045          */
00046         //virtual char * getWkbHexBuffer() = 0;
00047
00054         virtual GEOSGeometry* getGeosGeometry() = 0;
00055
00056
00061         virtual void releaseGeosGeometry (GEOSGeometry *the_geom) = 0;
00062
00063
00064         /*
00065          * \brief Called by Pal when it doesn't need the coordinates anymore
00066          * @param wkbBuffer is the WkbBuffer from PalGeometry::getWkbHexBuffer()
00067          */
00068         //virtual void releaseWkbHexBuffer(char *wkbBuffer) = 0;
00069
00070         /*
00071          * \brief Give back a label to display
00072          * Pal call this method when label will no move anymore.
00073          *
00074          * @param label the label to disploy
00075          */
00076         //virtual void addLabel(Label *label) = 0;
00077
00078         virtual ~PalGeometry() {}
00079     };
00080
00081 } // end namespace pal
00082
00083 #endif

programm6:palstat.h
00001 /*
00002  *   libpal - Automated Placement of Labels Library     http://pal.heig-vd.ch
00003  *
00004  *
00005  *   Copyright (C) 2007, 2008 MIS-TIC, HEIG-VD (University of Applied Sciences Western Switzerland)
00006  *   Copyright (C) 2008, 2009 IICT-SYSIN, HEIG-VD (University of Applied Sciences Western Switzerland)
00007  *
00008  *
00009  * This file is part of libpal.
00010  *
00011  * libpal is free software: you can redistribute it and/or modify
00012  * it under the terms of the GNU Lesser General Public License as published by
00013  * the Free Software Foundation, either version 3 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * libpal is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with libpal. If not, see .
00023  *
00024  */
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include
00028 #endif
00029
00030 #ifndef _PALSTAT_H_
00031 #define _PALSTAT_H_
00032
00033
00034 namespace pal {
00035
00039     class PalStat {
00040
00041         friend class Pal;
00042         friend class Problem;
00043
00044     private:
00045         int nbObjects;
00046         int nbLabelledObjects;
00047
00048         int nbLayers;
00049
00050         char **layersName; //[nbLayers]
00051         int *layersNbObjects; // [nbLayers]
00052         int *layersNbLabelledObjects; // [nbLayers]
00053
00054         PalStat();
00055
00056     public:
00057
00061         ~PalStat();
00062
00063
00067         int getNbObjects();
00068
00072         int getNbLabelledObjects();
00073
00077         int getNbLayers();
00078
00082         const char * getLayerName (int layerId);
00083
00087         int getLayerNbObjects (int layerId);
00088
00092         int getLayerNbLabelledObjects (int layerId);
00093     };
00094
00095 } // end namespace pal
00096
00097 #endif