GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GoDBContourRow.cxx
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 #include "GoDBContourRow.h"
36 #include "GoDBRecordSetHelper.h"
37 
39 #include "vtkSmartPointer.h"
40 
41 #include <iostream>
42 
44 {
45  this->InitializeMap();
46 }
47 
48 //-------------------------------------------------------------------------
49 
50 //-------------------------------------------------------------------------
51 GoDBContourRow::GoDBContourRow(vtkMySQLDatabase *DatabaseConnector,
52  vtkPolyData *TraceVisu, GoDBCoordinateRow Min, GoDBCoordinateRow Max,
53  unsigned int ImgSessionID) :
54  //GoDBTraceRow(DatabaseConnector, TraceVisu, Min, Max, ImgSessionID)
55  GoDBTraceRow()
56 {
57  this->InitializeMap();
58  this->SetImgSessionID(ImgSessionID);
59  this->SetTheDataFromTheVisu(DatabaseConnector, TraceVisu, Min, Max);
60 
61  if ( this->DoesThisBoundingBoxExist(DatabaseConnector) )
62  {
63  std::cout << "The bounding box already exists for this contour" << std::endl;
64  }
65 }
66 
67 //-------------------------------------------------------------------------
68 
69 //-------------------------------------------------------------------------
70 GoDBContourRow::GoDBContourRow(unsigned int ImagingSessionID) :
71  GoDBTraceRow()
72 {
73  this->InitializeMap();
74  this->SetImgSessionID(ImagingSessionID);
75 }
76 
77 //-------------------------------------------------------------------------
78 
79 //-------------------------------------------------------------------------
80 GoDBContourRow::GoDBContourRow(unsigned int iExistingID,
81  vtkMySQLDatabase *iDatabaseConnector) : GoDBTraceRow()
82 {
83  this->InitializeMap();
84  this->SetValuesForSpecificID(iExistingID, iDatabaseConnector);
85 }
86 
87 /*GoDBContourRow::GoDBContourRow(vtkMySQLDatabase* DatabaseConnector,
88  GoDBCoordinateRow Min, GoDBCoordinateRow Max,unsigned int ImgSessionID,
89  vtkPolyData* TraceVisu):
90  GoDBTraceRow(DatabaseConnector,TraceVisu,Min,Max,
91  ImgSessionID)
92 {
93  this->InitializeMap();
94  if (this->DoesThisBoundingBoxExist(DatabaseConnector))
95  {
96  std::cout<<"The bounding box already exists for this contour"<<std::endl;
97  }
98 }*/
99 //-------------------------------------------------------------------------
100 
101 //-------------------------------------------------------------------------
103 {
105  this->m_TableName = "contour";
106  this->m_TableIDName = "contourID";
107  this->m_CollectionName = "mesh";
108  this->m_CollectionIDName = "meshID";
109  this->m_MapRow[this->m_TableIDName] = std::string( "0" );//ConvertToString< int >(0);
110  this->m_MapRow["meshID"] = std::string( "0" );//ConvertToString< int >(0);
111 }
112 
113 //-------------------------------------------------------------------------
114 
115 //-------------------------------------------------------------------------
116 int GoDBContourRow::SaveInDB(vtkMySQLDatabase *DatabaseConnector)
117 {
118  return this->SaveInDBTemplate< GoDBContourRow >(DatabaseConnector, this);
119 }
120 
121 //-------------------------------------------------------------------------
122 
123 //-------------------------------------------------------------------------
124 /*void GoDBContourRow::SetCollectionID(int iCollectionID)
125 {
126  this->SetField< int >("meshID", iCollectionID);
127 }
128 
129 //-------------------------------------------------------------------------
130 
131 //-------------------------------------------------------------------------
132 void GoDBContourRow::ReInitializeMapAfterCast()
133 {
134  GoDBContourRow::InitializeMap();
135 }
136 
137 //-------------------------------------------------------------------------
138 
139 //-------------------------------------------------------------------------
140 void GoDBContourRow::SetTheDataFromTheVisu(
141  vtkMySQLDatabase *DatabaseConnector, vtkPolyData *TraceVisu,
142  GoDBCoordinateRow Min, GoDBCoordinateRow Max)
143 {
144 
145  GoDBTraceRow::SetTheDataFromTheVisu(DatabaseConnector, TraceVisu, Min, Max);
146 
147  if ( this->DoesThisBoundingBoxExist(DatabaseConnector) )
148  {
149  std::cout << "The bounding box already exists for this mesh" << std::endl;
150  }
151 }*/
152 //-------------------------------------------------------------------------
153 void GoDBContourRow::SetTheDataFromTheVisu(vtkMySQLDatabase *DatabaseConnector,
154  vtkPolyData *TraceVisu,
155  GoDBCoordinateRow iCoordMin,
156  GoDBCoordinateRow iCoordMax)
157 {
158  /*this->SetTheBoundingBox(DatabaseConnector, iCoordMin, iCoordMax);
159 
160  vtkSmartPointer< vtkPolyDataMySQLContourWriter > convert =
161  vtkSmartPointer< vtkPolyDataMySQLContourWriter >::New();
162  std::string PointsString = convert->GetMySQLText(TraceVisu);
163 
164  std::cout << "output string: " << PointsString << std::endl;
165 
166  this->SetField("Points", PointsString);
167 
168  if ( this->DoesThisBoundingBoxExist(DatabaseConnector) )
169  {
170  std::cout << "The bounding box already exists for this mesh" << std::endl;
171  }*/
172  this->SetTheDataFromTheVisuTemplate< vtkPolyDataMySQLContourWriter >(
173  DatabaseConnector, TraceVisu, iCoordMin, iCoordMax);
174 }
abstract class to be inherited by Contour,Mesh,Track and GoDBLineageRow
Definition: GoDBTraceRow.h:50
std::string m_TableIDName
Definition: GoDBRow.h:225
void SetTheDataFromTheVisu(vtkMySQLDatabase *DatabaseConnector, vtkPolyData *TraceVisu, GoDBCoordinateRow Min, GoDBCoordinateRow Max)
manages a map with keys matching fields of the gofiguredatabase Coordinate table and values of the ma...
bool SetValuesForSpecificID(int ID, vtkMySQLDatabase *iDatabaseConnector)
int DoesThisBoundingBoxExist(vtkMySQLDatabase *DatabaseConnector)
check if a trace already has the same bounding box
std::string m_TableName
Definition: GoDBRow.h:224
std::string m_CollectionIDName
check in the database if the Coordinate Min adn Max already exists, if yes fill the map["CoordIDMin"]...
Definition: GoDBTraceRow.h:154
void SetImgSessionID(unsigned int iImgSessionID)
set the ImagingSessionID field to iImgSessionID
virtual int SaveInDB(vtkMySQLDatabase *DatabaseConnector)
fill the contour map with the values gotten from the visualization
StringMapType m_MapRow
Definition: GoDBRow.h:223
virtual void InitializeMap()
virtual pure. initialize all the values of the map
std::string m_CollectionName
Definition: GoDBTraceRow.h:155
virtual void InitializeMap()
virtual pure. initialize all the values of the map