void SliceOrdering::Format(Json::Value& result) const
  {
    result = Json::objectValue;
    result["Type"] = (isVolume_ ? "Volume" : "Sequence");
    
    Json::Value tmp = Json::arrayValue;
    for (size_t i = 0; i < GetInstancesCount(); i++)
    {
      tmp.append(GetBasePath(ResourceType_Instance, GetInstanceId(i)) + "/file");
    }

    result["Dicom"] = tmp;

    Json::Value slicesShort = Json::arrayValue;

    tmp.clear();
    for (size_t i = 0; i < GetInstancesCount(); i++)
    {
      std::string base = GetBasePath(ResourceType_Instance, GetInstanceId(i));
      for (size_t j = 0; j < GetFramesCount(i); j++)
      {
        tmp.append(base + "/frames/" + boost::lexical_cast<std::string>(j));
      }

      Json::Value tmp2 = Json::arrayValue;
      tmp2.append(GetInstanceId(i));
      tmp2.append(0);
      tmp2.append(GetFramesCount(i));
      
      slicesShort.append(tmp2);
    }

    result["Slices"] = tmp;
    result["SlicesShort"] = slicesShort;
  }
Exemple #2
0
int main(int argc, char **argv) {
    try {
        std::string memMaxArg = std::string();
        char * varMemMax = getenv("NEXTFRACTAL_MAX_MEMORY");
        int varMemMaxLen = varMemMax != NULL ? strlen(varMemMax) : 0;
        if (varMemMaxLen > 0) {
            memMaxArg.append("-Xmx");
            memMaxArg.append(std::to_string(std::stoi(varMemMax)));
            memMaxArg.append("m");
        } else {
            memMaxArg.append("-Xmx3g");
        }
        std::string basePath = GetBasePath(GetExePath());
        std::cout << "Base path " << basePath << std::endl;
        std::string jarsPath = basePath + "/../Resources";
        std::string classpathArg = "-Djava.class.path=" + GetClasspath(jarsPath);
        std::string libPathArg = "-Djava.library.path=" + basePath + "/../Resources";
        std::string locPathArg = "-Dbrowser.location=" + basePath + "/../../../examples";
        const char *vm_arglist[] = {
            "-Djava.util.logging.config.class=com.nextbreakpoint.nextfractal.runtime.LogConfig",
            classpathArg.c_str(),
            libPathArg.c_str(),
            locPathArg.c_str(),
            memMaxArg.c_str(),
            0
        };
        struct start_args args(vm_arglist, "com/nextbreakpoint/nextfractal/runtime/javafx/NextFractalApp");
        pthread_t thr;
        pthread_create(&thr, NULL, start_java, &args);
        CFRunLoopRun();
    } catch (const std::runtime_error& e) {
        ShowAlert("Did you install Java JDK 8 or later?", e);
    }
}
  void ExportedResource::Format(Json::Value& item) const
  {
    item = Json::objectValue;
    item["Seq"] = static_cast<int>(seq_);
    item["ResourceType"] = EnumerationToString(resourceType_);
    item["ID"] = publicId_;
    item["Path"] = GetBasePath(resourceType_, publicId_);
    item["RemoteModality"] = modality_;
    item["Date"] = date_;

    // WARNING: Do not add "break" below and do not reorder the case items!
    switch (resourceType_)
    {
      case ResourceType_Instance:
        item["SOPInstanceUID"] = sopInstanceUid_;

      case ResourceType_Series:
        item["SeriesInstanceUID"] = seriesInstanceUid_;

      case ResourceType_Study:
        item["StudyInstanceUID"] = studyInstanceUid_;

      case ResourceType_Patient:
        item["PatientID"] = patientId_;
        break;

      default:
        throw OrthancException(ErrorCode_InternalError);
    }
  }
/*===========================================================================
 *
 * Class CSrResourceInstance Method - const char* GetFullFilenameAbs (void);
 *
 *=========================================================================*/
const char* CSrResourceInstance::GetFullFilenameAbs (void) {
  static CSString s_Buffer;

  s_Buffer  = GetBasePath();
  s_Buffer += GetFullFilename();
  
  return (s_Buffer);
}
ContentKaiVector::ContentKaiVector()
{
  InitializeCriticalSection(&m_critical);
  m_bDirty = false;
  m_nVersion = 0;

  vectorDataPath = GetBasePath();
}
bool CDictionaryBasedTempPath::operator==(const CDictionaryBasedTempPath& rhs) const
{
    return (GetBasePath() == rhs.GetBasePath())
        && (relPathElements.size() == rhs.relPathElements.size())
        && (std::equal ( relPathElements.begin()
                       , relPathElements.end()
                       , rhs.relPathElements.begin()));
}
Exemple #7
0
	bool ResourceLocation::CheckPath( void )
	{
		std::string PathB(RelativePath), BaseB(GetBasePath());

		SME::StringHelpers::MakeLower(PathB);
		SME::StringHelpers::MakeLower(BaseB);

		return PathB.find(BaseB) == std::string::npos;
	}
Exemple #8
0
void UpdateDlg::InstallFile()
{
    UpdateStatus(_("Please wait..."));
    UpdateRec* rec = GetRecFromListView();
    if (!rec)
    {
        wxMessageBox(_("No file selected!"), _("Error"), wxICON_ERROR);
        UpdateStatus(_("Ready"), 0, 0);
        return;
    }
    wxYield();

    if (rec->title == _T("WebUpdate Mirrors list"))
    {
        InstallMirrors(GetPackagePath() + rec->local_file);
        rec->installed = true;
        ApplyFilter();
        UpdateStatus(_("Ready"), 0, 0);
        return;
    }
    else if (!rec->installable)
    {
        UpdateStatus(_("Ready"), 0, 0);
        return;
    }

    if (!CreateDirRecursively(GetPackagePath()))
    {
        UpdateStatus(_("Ready"), 0, 0);
        wxMessageBox(_("Can't create directory ") + GetPackagePath(), _("Error"), wxICON_ERROR);
        return;
    }

    wxArrayString files;
    DevPakInstaller inst;
    if (inst.Install(rec->name, GetPackagePath() + rec->local_file, GetBasePath(), &files))
    {
//        wxFileName fname(GetPackagePath() + rec->local_file);
//        fname.SetExt("entry");
//        fname.SetName(rec->title);
//        CreateEntryFile(rec, fname.GetFullPath(), files);
        CreateEntryFile(rec, GetPackagePath() + rec->entry, files);
        wxMessageBox(_("DevPak installed"), _("Message"), wxICON_INFORMATION);

        // refresh installed_version
        rec->installed = true;
        rec->installed_version = rec->version;
        SetListColumnText(-1, 2, rec->installed_version);
    }
    else
    {
        wxMessageBox(_("DevPak was not installed.\nStatus:\n") + inst.GetStatus(), _("Error"), wxICON_ERROR);
    }
    UpdateStatus(_("Ready"), 0, 0);
}
Exemple #9
0
/*
 * Get a file or directory, relative to the installation base path.
 */
static char *GetFileInBasePath(const char *tail1, const char *tail2)
{
	char *base;
	char *temp;
	int baselen;
	int len;

	/* Get the base path for the program installation */
	base = GetBasePath();
	if(!base)
	{
		return 0;
	}
	baselen = strlen(base);

	/* Allocate additional space for the rest of the path */
	len = baselen + (tail1 ? strlen(tail1) : 0) + (tail2 ? strlen(tail2) : 0);
	temp = (char *)ILRealloc(base, len + 1);
	if(!temp)
	{
		ILFree(base);
		return 0;
	}
	base = temp;

	/* Construct the final path, normalizing path separators as we go */
	len = baselen;
	while(tail1 != 0 && *tail1 != '\0')
	{
		if(*tail1 == '/')
		{
			base[len++] = DIR_SEP;
		}
		else
		{
			base[len++] = *tail1;
		}
		++tail1;
	}
	while(tail2 != 0 && *tail2 != '\0')
	{
		if(*tail2 == '/')
		{
			base[len++] = DIR_SEP;
		}
		else
		{
			base[len++] = *tail2;
		}
		++tail2;
	}
	base[len] = '\0';
	return base;
}
Exemple #10
0
// clears the tile cache for the given map
void MgdTileCache::Clear(MgMapBase* map)
{
    if (map != NULL)
    {
        STRING basePath = GetBasePath(map);

        // delete main map directory
        if (!basePath.empty())
            MgFileUtil::DeleteDirectory(basePath, true, false);
    }
}
Exemple #11
0
// clears the tile cache for the given map
void MgdTileCache::Clear(MgResourceIdentifier* mapDef)
{
    // the resource must be a map definition
    if (mapDef != NULL && mapDef->GetResourceType() == MgResourceType::MapDefinition)
    {
        STRING basePath = GetBasePath(mapDef);

        // delete main map directory
        if (!basePath.empty())
            MgFileUtil::DeleteDirectory(basePath, true, false);
    }
}
Exemple #12
0
/*
todo: 
- destination coding 
	if blank then it should use the extension of the source file
	if *.* then it should use the extension from the source file
	if *.png then it should store it as a png file
	if *.jpg then it should store it as a jpg file
	etc..
*/
FileList::FileList(std::string src, std::string dest, std::string append)
{
	FileInfo* info;
	std::string newName;
	std::string srcExt;
	std::string destExt;
	FileType destType;

	std::string tmpBase;

	std::cout << "FileList::FileList(src) == " << src << "\n";

	tmpBase = GetBasePath( src );

	
	if( tmpBase == src )
	{
		GetCWD(tmpBase);
		// no wildcard or filename information was provided
		//return;
	}

	std::cout << "FileList::FileList.tmpBase == " << tmpBase << "\n";
	
	// open the basepath dir
	DIR * dir;
	
	dir = opendir(tmpBase.c_str());
	
	//TODO : need to see if the open dir fails!!
	
	dirent* de;
	
	std::string tmpName;
	tmpName = GetFilename(src);

	
	while((de = readdir(dir)) != NULL)
	{
		if( de->d_type == DT_REG)
		{
			// we need to see if it matches the filename/wildcard stuff?
			if( IsMatch( tmpName, de->d_name ) == true )
			{
				std::cout << "file match found\n";
				info = GetInfo(de, src, dest, append);

				mFiles.push_back( info );
			}

		}
	}
}
wxString CompileTargetBase::GetDepsOutput() const
{
    if (m_TargetType == ttCommandsOnly)
        return wxEmptyString;
    wxString out;
    if (m_DepsOutput.IsEmpty())
    {
        out = GetBasePath();
        if (out.IsEmpty() || out.Matches(_T(".")))
             return _T(".deps");
        else
            return out + wxFileName::GetPathSeparator() + _T(".deps");
    }
    return m_DepsOutput;
}
bool HSProp_Meidusha::InitProp( const PropInfo* pPropInfo )
{
	std::string fileName = GetBasePath() + pPropInfo->localname();

	CCSprite* pNode_0 = HSCCSprite::create(fileName.c_str());
	HSGraySprite* pNode_1 = HSGraySprite::create(fileName.c_str());
	pNode_1->setScale(1.02f);

	m_pMenuItem = CCMenuItemSprite::create(pNode_0,pNode_1,this,menu_selector(HSProp_Meidusha::Call));
	
	CCMenu* pMenu = CCMenu::create(m_pMenuItem,NULL);
	pMenu->setPosition(CCPointZero);
	this->addChild(pMenu);

	return true;
}
JString
CBCommandPathInput::GetTextForChoosePath()
	const
{
	if (!GetText().IsEmpty() && GetText().GetFirstCharacter() == '@')
		{
		JString s;
		if (!GetBasePath(&s) &&
			!JGetHomeDirectory(&s))
			{
			s = JGetRootDirectory();
			}
		return s;
		}
	else
		{
		return JXPathInput::GetTextForChoosePath();
		}
}
CDictionaryBasedTempPath CDictionaryBasedTempPath::GetCommonRoot
    (const CDictionaryBasedTempPath& rhs) const
{
    // short-cut: different base directories anyway?

    if (rhs.GetIndex() != GetIndex())
        return CDictionaryBasedTempPath (inherited::GetCommonRoot (rhs));

    // match relative paths

    typedef std::vector<std::string>::const_iterator IT;
    IT begin = relPathElements.begin();
    IT end = relPathElements.end();
    IT iter = begin;

    IT rhsEnd = relPathElements.end();
    IT rhsIter = relPathElements.begin();

    while ((iter != end) && (rhsIter != rhsEnd) && (*iter == *rhsIter))
    {
        ++iter;
        ++rhsIter;
    }

    // construct the result

    CDictionaryBasedTempPath result (GetBasePath());
    result.relPathElements.insert (result.relPathElements.begin(), begin, iter);

    // update the debug-only _path member

#ifdef _DEBUG
    result._path = result.GetPath();
#endif

    return result;
}
Exemple #17
0
///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Generate tile and lock pathnames.
///
void MgdTileCache::GeneratePathnames(MgResourceIdentifier* mapDef, int scaleIndex,
    CREFSTRING group, int tileColumn, int tileRow,
    STRING& tilePathname, STRING& lockPathname, bool createFullPath)
{
    STRING fileName = L"/" + GetTileName(tileRow, tileColumn) + L".";
    STRING basePath = GetBasePath(mapDef);

    if (createFullPath)
    {
        tilePathname = CreateFullPath(basePath, scaleIndex, group, tileColumn, tileRow);
    }
    else
    {
        tilePathname = GetFullPath(basePath, scaleIndex, group, tileColumn, tileRow);
    }

    // Generate the tile and lock pathnames
    //     <tilePathname> = <fullPath>/<row>_<column>.png/jpg
    //     <lockPathname> = <fullPath>/<row>_<column>.lck
    tilePathname += fileName;
    lockPathname = tilePathname;
    if (MgdTileParameters::tileFormat == MgdImageFormats::Jpeg)
    {
        tilePathname += L"jpg";
    }
    else if (MgdTileParameters::tileFormat == MgdImageFormats::Gif)
    {
        tilePathname += L"gif";
    }
    else
    {
        tilePathname += L"png";
    }

    lockPathname += L"lck";
}
Exemple #18
0
Framework::CConfig::PathType CAppConfig::BuildConfigPath()
{
	return GetBasePath() / CONFIG_FILENAME;
}
Exemple #19
0
tstring FileManager::GetCrashPath()
{
	tstring path = GetBasePath() + _T("\\Crash");
	CreateFolder(path.c_str());
	return path;
}
Exemple #20
0
STRING MgdTileCache::CreateFullPath(MgResourceIdentifier* mapDef, int scaleIndex, CREFSTRING group, int tileColumn, int tileRow)
{
    return CreateFullPath(GetBasePath(mapDef), scaleIndex, group, tileColumn, tileRow);
}
Exemple #21
0
STRING MgdTileCache::CreateFullPath(MgMapBase* map, int scaleIndex, CREFSTRING group, int tileColumn, int tileRow)
{
    return CreateFullPath(GetBasePath(map), scaleIndex, group, tileColumn, tileRow);
}
Exemple #22
0
tstring FileManager::GetHistoryPath()
{
	tstring path = GetBasePath() + _T("\\History");
	CreateFolder(path.c_str());
	return path;
}
Exemple #23
0
// gets the base path to use with the tile cache for the given map
STRING MgdTileCache::GetBasePath(MgMapBase* map)
{
    assert(NULL != map);
    Ptr<MgResourceIdentifier> mapDef = map->GetMapDefinition();
    return GetBasePath(mapDef);
}
Exemple #24
0
tstring FileManager::GetThumbPath()
{
	tstring path = GetBasePath() + _T("\\Thumb");
	CreateFolder(path.c_str());
	return path;
}
Exemple #25
0
tstring FileManager::GetFavoritePath()
{
	tstring path = GetBasePath() + _T("\\Favorite");
	CreateFolder(path.c_str());
	return path;
}
Exemple #26
0
tstring FileManager::GetReportPath()
{
	tstring path = GetBasePath() + _T("\\Report");
	CreateFolder(path.c_str());
	return path;
}
Exemple #27
0
	std::string ResourceLocation::GetFullPath() const
	{
		return GetBasePath() + RelativePath;
	}
Exemple #28
0
wxString UpdateDlg::GetPackagePath() const
{
    return GetBasePath() + _T("Packages") + wxFILE_SEP_PATH;
}
  static void AnonymizeOrModifyResource(DicomModification& modification,
                                        MetadataType metadataType,
                                        ChangeType changeType,
                                        ResourceType resourceType,
                                        RestApiPostCall& call)
  {
    bool isFirst = true;
    Json::Value result(Json::objectValue);

    ServerContext& context = OrthancRestApi::GetContext(call);

    typedef std::list<std::string> Instances;
    Instances instances;
    std::string id = call.GetUriComponent("id", "");
    context.GetIndex().GetChildInstances(instances, id);

    if (instances.empty())
    {
      return;
    }


    /**
     * Loop over all the instances of the resource.
     **/

    for (Instances::const_iterator it = instances.begin(); 
         it != instances.end(); ++it)
    {
      LOG(INFO) << "Modifying instance " << *it;

      std::auto_ptr<ServerContext::DicomCacheLocker> locker;

      try
      {
        locker.reset(new ServerContext::DicomCacheLocker(OrthancRestApi::GetContext(call), *it));
      }
      catch (OrthancException&)
      {
        // This child instance has been removed in between
        continue;
      }


      ParsedDicomFile& original = locker->GetDicom();
      DicomInstanceHasher originalHasher = original.GetHasher();


      /**
       * Compute the resulting DICOM instance.
       **/

      std::auto_ptr<ParsedDicomFile> modified(original.Clone());
      modification.Apply(*modified);

      DicomInstanceToStore toStore;
      toStore.SetParsedDicomFile(*modified);


      /**
       * Prepare the metadata information to associate with the
       * resulting DICOM instance (AnonymizedFrom/ModifiedFrom).
       **/

      DicomInstanceHasher modifiedHasher = modified->GetHasher();

      if (originalHasher.HashSeries() != modifiedHasher.HashSeries())
      {
        toStore.AddMetadata(ResourceType_Series, metadataType, originalHasher.HashSeries());
      }

      if (originalHasher.HashStudy() != modifiedHasher.HashStudy())
      {
        toStore.AddMetadata(ResourceType_Study, metadataType, originalHasher.HashStudy());
      }

      if (originalHasher.HashPatient() != modifiedHasher.HashPatient())
      {
        toStore.AddMetadata(ResourceType_Patient, metadataType, originalHasher.HashPatient());
      }

      assert(*it == originalHasher.HashInstance());
      toStore.AddMetadata(ResourceType_Instance, metadataType, *it);


      /**
       * Store the resulting DICOM instance into the Orthanc store.
       **/

      std::string modifiedInstance;
      if (context.Store(modifiedInstance, toStore) != StoreStatus_Success)
      {
        LOG(ERROR) << "Error while storing a modified instance " << *it;
        return;
      }

      // Sanity checks in debug mode
      assert(modifiedInstance == modifiedHasher.HashInstance());


      /**
       * Compute the JSON object that is returned by the REST call.
       **/

      if (isFirst)
      {
        std::string newId;

        switch (resourceType)
        {
          case ResourceType_Series:
            newId = modifiedHasher.HashSeries();
            break;

          case ResourceType_Study:
            newId = modifiedHasher.HashStudy();
            break;

          case ResourceType_Patient:
            newId = modifiedHasher.HashPatient();
            break;

          default:
            throw OrthancException(ErrorCode_InternalError);
        }

        result["Type"] = EnumerationToString(resourceType);
        result["ID"] = newId;
        result["Path"] = GetBasePath(resourceType, newId);
        result["PatientID"] = modifiedHasher.HashPatient();
        isFirst = false;
      }
    }

    call.GetOutput().AnswerJson(result);
  }
void AssimpParser::LoadTextures()
{
	ILboolean success;

	/* Before calling ilInit() version should be checked. */
	if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION)
	{
		/// wrong DevIL version ///
		std::string err_msg = "Wrong DevIL version. Old devil.dll in system32/SysWow64?";
		char* cErr_msg = (char *) err_msg.c_str();
		return;
	}

	ilInit(); /* Initialization of DevIL */
	if (scene->HasTextures()) return;

	for (unsigned int m=0; m<scene->mNumMaterials; m++)
	{
		int texIndex = 0;
		aiReturn texFound = AI_SUCCESS;

		aiString path;	// filename

		while (texFound == AI_SUCCESS)
		{
			texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path);
			//textureIdMap[path.data] = NULL; //fill map with textures, pointers still NULL yet
			if(texFound == AI_SUCCESS)
			{
				std::string pathStr = std::string(path.C_Str());
				Texture::textureMap.insert(std::pair<std::string, std::shared_ptr<Texture>>(pathStr, std::shared_ptr<Texture>(new Texture(pathStr))));
			}

			texIndex++;
		}
	}

	int numTextures = Texture::GetNumberOfTextures();

	ILuint* imageIds = NULL;
	imageIds = new ILuint[numTextures];
	ilGenImages(numTextures, imageIds); /* Generation of numTextures image names */

	textureIds = new GLuint[numTextures];
	glGenTextures(numTextures, textureIds); /* Texture name generation */

	std::map<std::string, std::shared_ptr<Texture>>::iterator itr = Texture::textureMap.begin();

	std::string basepath = GetBasePath(path);
	for (int i=0; i<numTextures; i++)
	{
		std::string filename = (*itr).first;  // get filename
		(*itr).second->SetTextureID(textureIds[i]);	  // save texture id for filename in map
		itr++;								  // next texture

		ilBindImage(imageIds[i]); /* Binding of DevIL image name */
		std::string fileloc = basepath + filename;	/* Loading of image */
		success = ilLoadImage(fileloc.c_str());

		if (success) /* If no error occured: */
		{
			if(ilGetInteger(IL_IMAGE_FORMAT) == IL_RGB)
			{
				success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
			}
			else if(ilGetInteger(IL_IMAGE_FORMAT) == IL_RGBA)
			{
				success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
			}

			if(!success)
			{
				return;
			}

			glBindTexture(GL_TEXTURE_2D, textureIds[i]); /* Binding of texture name */
			GLenum e = glGetError();
			//redefine standard texture values
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* We will use linear
			interpolation for magnification filter */
			e = glGetError();
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); /* We will use linear
			interpolation for minifying filter */
			e = glGetError();
			glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
				ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
				ilGetData()); /* Texture specification */
			e = glGetError();

			glBindTexture(GL_TEXTURE_2D, 0);
		}

		ilBindImage(0);
	}

	ilDeleteImages(numTextures, imageIds); /* Because we have already copied image data into texture data we can release memory used by image. */

	//Cleanup
	delete [] imageIds;
	imageIds = NULL;
}