1 | // ----------------------------------------------------------------------- |
---|
2 | // detection.cc : Member functions for the Detection class. |
---|
3 | // ----------------------------------------------------------------------- |
---|
4 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
5 | // |
---|
6 | // This program is free software; you can redistribute it and/or modify it |
---|
7 | // under the terms of the GNU General Public License as published by the |
---|
8 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
9 | // option) any later version. |
---|
10 | // |
---|
11 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
12 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
13 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
14 | // for more details. |
---|
15 | // |
---|
16 | // You should have received a copy of the GNU General Public License |
---|
17 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
18 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
19 | // |
---|
20 | // Correspondence concerning Duchamp may be directed to: |
---|
21 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
22 | // Postal address: Dr. Matthew Whiting |
---|
23 | // Australia Telescope National Facility, CSIRO |
---|
24 | // PO Box 76 |
---|
25 | // Epping NSW 1710 |
---|
26 | // AUSTRALIA |
---|
27 | // ----------------------------------------------------------------------- |
---|
28 | #include <vector> |
---|
29 | #include <cpgplot.h> |
---|
30 | #include <duchamp/duchamp.hh> |
---|
31 | #include <duchamp/Detection/detection.hh> |
---|
32 | #include <duchamp/PixelMap/Voxel.hh> |
---|
33 | #include <duchamp/PixelMap/Object3D.hh> |
---|
34 | |
---|
35 | using namespace PixelInfo; |
---|
36 | |
---|
37 | namespace duchamp |
---|
38 | { |
---|
39 | void Detection::drawBorders(int xoffset, int yoffset) |
---|
40 | { |
---|
41 | /// @details |
---|
42 | /// For a given object, draw borders around the spatial extent of the object. |
---|
43 | /// \param xoffset The offset from 0 of the x-axis of the plotting window |
---|
44 | /// \param yoffset The offset from 0 of the y-axis of the plotting window |
---|
45 | |
---|
46 | if(!cpgtest()){ |
---|
47 | DUCHAMPERROR("Draw Borders","There is no PGPlot device open."); |
---|
48 | } |
---|
49 | else{ |
---|
50 | |
---|
51 | float x1,x2,y1,y2; |
---|
52 | cpgqwin(&x1,&x2,&y1,&y2); |
---|
53 | int xsize = int(x2 - x1) + 1; |
---|
54 | int ysize = int(y2 - y1) + 1; |
---|
55 | |
---|
56 | cpgswin(0,xsize-1,0,ysize-1); |
---|
57 | |
---|
58 | std::vector<std::vector<Voxel> > vertexSets = this->getVertexSet(); |
---|
59 | |
---|
60 | for(size_t n=0;n<vertexSets.size();n++){ |
---|
61 | // for each set of vertices |
---|
62 | |
---|
63 | cpgmove(vertexSets[n][0].getX()-xoffset,vertexSets[n][0].getY()-yoffset); |
---|
64 | for(size_t i=1;i<vertexSets[n].size();i++) |
---|
65 | cpgdraw(vertexSets[n][i].getX()-xoffset,vertexSets[n][i].getY()-yoffset); |
---|
66 | |
---|
67 | } |
---|
68 | |
---|
69 | cpgswin(x1,x2,y1,y2); |
---|
70 | |
---|
71 | } |
---|
72 | |
---|
73 | } |
---|
74 | |
---|
75 | } |
---|