52 std::string iPassword,
int iImagingSessionID,
53 std::string iFilename,
int iCurrentTimePoint)
60 this->
m_InFile.open(iFilename.c_str(), std::ifstream::in);
78 std::string LineContent;
81 MapSubCellTypeIDs, MapCoordIDs);
100 std::string LineContent;
103 MapSubCellTypeIDs, MapCoordIDs);
105 MapSubCellTypeIDs,
true);
126 std::string LineContent;
128 getline(this->
m_InFile, LineContent);
131 getline (this->
m_InFile, LineContent);
133 while ( this->
FindFieldName(LineContent) !=
"NumberOflineage" )
136 getline(this->
m_InFile, LineContent);
139 if ( EntitiesNumber != 0 )
143 std::cout <<
"There was supposed to be only the name of the entity to save,the entity will not be saved";
144 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
145 std::cout << std::endl;
149 if ( NameEntity ==
"color" )
151 LineContent = this->SaveImportedEntitiesInDatabase< GoDBColorRow >(
152 EntitiesNumber, ioMapColorIDs);
154 if ( NameEntity ==
"celltype" )
156 LineContent = this->SaveImportedEntitiesInDatabase< GoDBCellTypeRow >(
157 EntitiesNumber, ioMapCellTypeIDs);
159 if ( NameEntity ==
"subcellulartype" )
161 LineContent = this->SaveImportedEntitiesInDatabase< GoDBSubCellTypeRow >(
162 EntitiesNumber, ioMapSubCellTypeIDs);
164 if ( NameEntity ==
"coordinate" )
166 LineContent = this->SaveImportedEntitiesInDatabase< GoDBCoordinateRow >(
167 EntitiesNumber, ioMapCoordIDs);
169 if ( NameEntity !=
"color" && NameEntity !=
"celltype"
170 && NameEntity !=
"subcellulartype" && NameEntity !=
"coordinate" )
172 std::cout <<
"The name of the entity doesn't correspond to any of the no traces entity";
173 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
174 std::cout << std::endl;
186 const std::string & iLineContent,
189 bool SaveIntensities)
196 std::string LineContent = iLineContent;
202 this->SaveTraces< GoDBLineageRow >(iMapColorIDs, iMapCoordIDs,
203 MapLineageIDs, LineContent,
205 MapIDsSpecificOne, MapIDsSpecificTwo );
212 this->SaveTraces< GoDBTrackRow >(iMapColorIDs, iMapCoordIDs, MapLineageIDs,
214 MapIDsSpecificOne, MapIDsSpecificTwo );
219 this->SaveTraces< GoDBMeshRow >(iMapColorIDs, iMapCoordIDs, MapTrackIDs,
220 LineContent, this->
m_NewMeshIDs, MapMeshIDs, iMapCellTypeIDs,
224 if ( SaveIntensities )
233 this->SaveTraces< GoDBContourRow >(iMapColorIDs, iMapCoordIDs, MapMeshIDs,
235 MapIDsSpecificOne, MapIDsSpecificTwo );
244 size_t BegName = iLine.find(
"<", 0) + 1;
245 size_t EndName = iLine.find(
">", 0);
246 size_t NameLength = EndName - BegName;
247 std::string oName = iLine.substr(BegName, NameLength);
249 if ( oName.find(
"/", 0) == 0 )
251 oName = oName.substr(1);
261 size_t BegValue = iLine.find(
">", 0) + 1;
262 size_t EndValue = iLine.find(
"<", BegValue);
264 if ( EndValue != iLine.npos )
266 size_t ValueLength = EndValue - BegValue;
267 return iLine.substr(BegValue, ValueLength);
269 return "NoValueOnTheLine";
277 size_t BegValue = iLine.find(
"NumberOf", 0);
279 if ( BegValue != iLine.npos )
311 while ( this->
FindFieldName(ioLineContent) !=
"NumberOfchannel" )
313 getline (this->
m_InFile, ioLineContent);
317 getline(this->
m_InFile, ioLineContent);
318 if ( EntitiesNumber != 0 )
320 while ( this->
FindFieldName(ioLineContent) !=
"NumberOfintensity" )
324 std::cout <<
"There was supposed to be only the name of the entity to save,the entity will not be saved";
325 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
326 std::cout << std::endl;
329 if ( NameEntity !=
"channel" )
331 std::cout <<
"The name of the entity should be channel but is actually different";
332 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
333 std::cout << std::endl;
338 ioLineContent = this->GetValuesFromInfile< GoDBChannelRow >(NewChannel);
339 this->ReplaceTheFieldWithNewIDs< GoDBChannelRow >(
340 iMapColorIDs,
"ColorID", NewChannel);
341 int OldID = NewChannel.
GetMapValue<
int>(
"ChannelID");
342 NewChannel.
SetField(
"ChannelID",
"0");
349 getline(this->
m_InFile, ioLineContent);
350 if ( EntitiesNumber != 0 )
352 while ( this->
FindFieldName(ioLineContent) !=
"ExportTraces" )
356 std::cout <<
"There was supposed to be only the name of the entity to save,the entity will not be saved";
357 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
358 std::cout << std::endl;
361 if ( NameEntity !=
"intensity" )
363 std::cout <<
"The name of the entity should be channel but is actually different";
364 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
365 std::cout << std::endl;
370 ioLineContent = this->GetValuesFromInfile< GoDBIntensityRow >(NewIntensity);
371 this->ReplaceTheFieldWithNewIDs< GoDBIntensityRow >(
372 iMapMeshIDs,
"meshID", NewIntensity);
373 this->ReplaceTheFieldWithNewIDs< GoDBIntensityRow >(
374 MapChannelIDs,
"ChannelID", NewIntensity);
375 NewIntensity.
SetField(
"IntensityID",
"0");
void ImportContours()
get the data needed from the import file to save the contours listed in it, including the color...
manages a map with keys matching fields of the gofiguredatabase Intensity table and values of the map...
std::vector< int > m_NewLineageIDs
GoDBImport(std::string iServerName, std::string iLogin, std::string iPassword, int iImagingSessionID, std::string iFilename, int iCurrentTimePoint)
void SaveIntensityForMesh(std::string &ioLineContent, const IntMapType &iMapMeshIDs, const IntMapType &iMapColorIDs)
fill the info needed for the new imported contours to add them in the visu
bool CloseDatabaseConnection(vtkMySQLDatabase *DatabaseConnector)
return true if the connection has been closed, false if the connection was already closed ...
std::vector< int > m_NewTracksIDs
vtkMySQLDatabase * OpenDatabaseConnection(std::string ServerName, std::string login, std::string Password, std::string DBName)
int SaveInDB(vtkMySQLDatabase *DatabaseConnector)
std::vector< int > m_NewContourIDs
std::map< int, int > IntMapType
std::string FindFieldName(std::string iLine)
Return the name of the field contained in the line.
std::vector< int > m_NewMeshIDs
int SaveInDB(vtkMySQLDatabase *DatabaseConnector)
bool IsLineForNumberOfEntities(std::string iLine)
Return true if the line containes "Number Of".
vtkMySQLDatabase * m_DatabaseConnector
void SaveTracesEntities(const IntMapType &iMapColorIDs, const IntMapType &iMapCoordIDs, const std::string &iLineContent, const IntMapType &iMapCellTypeIDs, const IntMapType &iMapSubCellTypeIDs, bool SaveIntensities=false)
Get the info for the traces from the import file and from the matching IDs maps previously filled...
std::string GetValueForTheLine(std::string iLine)
Return the value contained in the line and "NoValueOnTheLine" if the line doesn't contain any...
void SetField(const std::string &key, const T &value)
convert the value into a string and assign it to the key in the map
void ImportMeshes()
get the data needed from the import file to save the meshes listed in it, including the color...
manages a map with keys matching fields of the gofiguredatabase Channel table and values of the map m...
void ImportTracks()
get the data needed from the import file to save the tracks listed in it, including the color...
std::string SaveNoTracesEntities(IntMapType &ioMapColorIDs, IntMapType &ioMapCellTypeIDs, IntMapType &ioMapSubCellTypeIDs, IntMapType &ioMapCoordIDs)
Get the values from the Infile, save the non traces entities, fill the matching map for old and new I...
std::string GetMapValue(const std::string &key)
return the value for the field map[key] after having removed the " at the beginning and at the end of...