97 char currentPath[_MAX_PATH];
98 GetModuleFileName(NULL, currentPath, _MAX_PATH);
107 pPath = getenv (
"HOME");
124 xercesc::DOMDocument *doc;
128 XMLPlatformUtils::Initialize();
130 catch (
const XMLException& toCatch) {
131 char* message = XMLString::transcode(toCatch.getMessage());
132 cout <<
"Error during initialization! :\n"
134 XMLString::release(&message);
141 OsirixParser->setDoNamespaces(
true);
142 OsirixParser->setDoSchema(
true);
143 OsirixParser->setValidationScheme(XercesDOMParser::Val_Always );
144 OsirixParser->setExternalNoNamespaceSchemaLocation(XMLString::transcode(
schema.c_str()));
145 OsirixParser->setValidationSchemaFullChecking(
true);
146 OsirixParser->setValidationConstraintFatal(
true);
147 OsirixParser->setExitOnFirstFatalError(
true);
152 OsirixParser->setErrorHandler(errHandler);
156 OsirixParser->parse(xmlfile);
159 if(OsirixParser->getErrorCount() > 0){
172 catch (
const XMLException& toCatch) {
173 char* message = XMLString::transcode(toCatch.getMessage());
174 cout <<
"Exception message is: \n"
176 XMLString::release(&message);
181 catch (
const DOMException& toCatch) {
182 char* message = XMLString::transcode(toCatch.msg);
183 cout <<
"Exception message is: \n"
185 XMLString::release(&message);
191 cout <<
"Unexpected Exception \n" ;
197 std::cout<<
"parsing document..."<<std::endl;
200 doc = OsirixParser->getDocument();
218 DOMNode* node = list->item(0);
219 this->
errorline = XMLString::transcode(node->getTextContent());
235 node = list->item(list->getLength()-1);
239 if(node->getChildNodes()->getLength()>0){
252 DOMNode* node, *childnode, *childnode1, *childarray;
253 std::string point_mm, point_px, osirixinteger, imageindex, temp;
254 DOMNodeList* childlist;
264 for(i = 0; i < (int)(list->getLength()); i++){
265 node = list->item(i);
266 childlist = node->getChildNodes();
267 for(j = 0; j < (int)(childlist->getLength());j++){
268 childnode = childlist->item(j);
269 temp = XMLString::transcode(childnode->getTextContent());
272 if(point_mm.compare(temp)==0){
273 childarray = childlist->item(j+2);
278 }
else if(point_px.compare(temp)==0){
279 childarray = childlist->item(j+2);
284 }
else if(imageindex.compare(temp) == 0){
285 childnode1 = childlist->item(j+2);
286 if(childnode1 != NULL && osirixinteger.compare(XMLString::transcode(childnode1->getNodeName())) == 0){
287 _imageindex = atoi(XMLString::transcode(childnode1->getTextContent()));
289 }
else if(osirixname.compare(temp) == 0) {
291 childnode1 = childlist->item(j+2);
292 if(childnode1 != NULL && osirixstring.compare(XMLString::transcode(childnode1->getNodeName())) == 0){
293 char* roiname = XMLString::transcode(childnode1->getTextContent());
302 int i, stringfound0, stringfound1;
304 string temp, osirix_string, numx, numy, numz;
305 vector<double>* vectorx;
306 vector<double>* vectory;
307 vector<double>* vectorz;
311 vectorx =
new vector<double>;
312 vectory =
new vector<double>;
313 vectorz =
new vector<double>;
317 for(i = 0; i < (int)(list->getLength()); i++){
318 node = list->item(i);
319 if(osirix_string.compare(XMLString::transcode(node->getNodeName()))==0){
320 temp = XMLString::transcode(node->getTextContent());
322 stringfound0 = temp.find(
",",0);
323 numx = temp.substr(1, stringfound0-1);
325 stringfound1 = temp.find(
",",stringfound0+1);
326 numy = temp.substr(stringfound0+1, stringfound1-stringfound0-1);
328 stringfound0 = temp.find(
")",stringfound1+1);
329 numz = temp.substr(stringfound1+1, stringfound0-stringfound1-1);
331 x = atof(numx.c_str());
332 y = atof(numy.c_str());
333 z = atof(numz.c_str());
335 vectorx->push_back(x);
336 vectory->push_back(y);
337 vectorz->push_back(z);
340 if(vectorx->size() > 0){
341 vectorxyz.push_back(*vectorx);
342 vectorxyz.push_back(*vectory);
343 vectorxyz.push_back(*vectorz);
350 int i, stringfound0, stringfound1;
352 string temp, osirix_string, numx, numy;
353 vector<double>* vectorx;
354 vector<double>* vectory;
355 vector<double>* vectorz;
359 vectorx =
new vector<double>;
360 vectory =
new vector<double>;
361 vectorz =
new vector<double>;
365 for(i = 0; i < (int)(list->getLength()); i++){
366 node = list->item(i);
367 if(osirix_string.compare(XMLString::transcode(node->getNodeName()))==0){
368 temp = XMLString::transcode(node->getTextContent());
370 stringfound0 = temp.find(
",",0);
371 numx = temp.substr(1, stringfound0-1);
373 stringfound1 = temp.find(
")",stringfound0+1);
374 numy = temp.substr(stringfound0+1, stringfound1-stringfound0-1);
376 x = atof(numx.c_str());
377 y = atof(numy.c_str());
379 vectorx->push_back(x);
380 vectory->push_back(y);
384 if(vectorx->size() > 0){
385 vectorxyz.push_back(*vectorx);
386 vectorxyz.push_back(*vectory);
387 vectorxyz.push_back(*vectorz);
397 for(
int i = 0; i < (int)(list->getLength()); i++){
398 DOMNode* node = list->item(i);
399 if(tagname.compare(XMLString::transcode(node->getNodeName()))==0){
400 std::cout<<
"NODENAME "<<XMLString::transcode(node->getTextContent())<<std::endl;
401 vect.push_back(XMLString::transcode(node->getTextContent()));
424 fprintf(pFile,
" 0\n");
429 map<int, vectorXYZ>::iterator itPX;
430 vector<double> vectx, vecty, vectz;
432 int dimz = 0, dimy = 0;
436 dimy = _extent[3] - _extent[2] + 1;
444 vectx = ((*itPX).second)[0];
445 vecty = ((*itPX).second)[1];
446 vectz = ((*itPX).second)[2];
450 valuez = (int) vectz[0] /
_spacing[2];
453 fprintf(pFile,
" 1 %d 1 1 1 1\n",dimz - valuez);
455 fprintf(pFile,
" 1\n");
457 fprintf(pFile,
" %d\n", vectz.size());
458 for(i = 0; i < vectx.size(); i++){
459 fprintf(pFile,
"%f %f 900.00\n", vectx[i]/
_spacing[0], dimy - vecty[i]/
_spacing[1]);
463 fprintf(pFile,
" 1\n");
473 fprintf(pFile,
"\n");
475 fprintf(pFile,
"\n");
520 sprintf_s(c,
"%d",(
int)(exc.getColumnNumber()));
522 sprintf(c,
"%d",(
int)(exc.getColumnNumber()));
529 sprintf_s(c,
"%d",(
int)(exc.getLineNumber()));
531 sprintf(c,
"%d",(
int)(exc.getLineNumber()));
536 errormsg += XMLString::transcode(exc.getMessage());
545 sprintf_s(c,
"%d",(
int)(exc.getColumnNumber()));
547 sprintf(c,
"%d",(
int)(exc.getColumnNumber()));
554 sprintf_s(c,
"%d",(
int)(exc.getLineNumber()));
556 sprintf(c,
"%d",(
int)(exc.getLineNumber()));
561 errormsg += XMLString::transcode(exc.getMessage());