Example #1
0
/// Sets the filename of the project
void Workspace::setFilename( const QString& filename )
{
    filename_ = filename;
    if( !filename_.endsWith(fileExtension() ) ) {
        filename_ += fileExtension();
    }

    // currently the name is set to the basename of the project
    name_ = QFileInfo(filename).baseName();
}
/**Documentation
 *  test for the class "ToFImageWriter".
 */
int mitkToFImageWriterTest(int /* argc */, char* /*argv*/[])
{
  MITK_TEST_BEGIN("ToFImageWriter");

  //testing initialization of object
  mitk::ToFImageWriter::Pointer tofWriter = mitk::ToFImageWriter::New();
  MITK_TEST_CONDITION_REQUIRED(tofWriter.GetPointer(), "Testing initialization of test object!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetExtension()!= "", "Test initialization of member extension!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetDistanceImageFileName()== "", "Test initialization of member distanceImageFileName!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetAmplitudeImageFileName()== "", "Test initialization of member amplitudeImageFileName!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetIntensityImageFileName()== "", "Test initialization of member intnensityImageFileName!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetDistanceImageSelected()==true, "Test initialization of member distanceImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetAmplitudeImageSelected()==false, "Test initialization of member amplitudeImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetIntensityImageSelected()==false, "Test initialization of member intensityImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetRGBImageSelected()==false, "Test initialization of member rgbImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFCaptureWidth()== 200, "Test initialization of member captureWidth!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFCaptureHeight()== 200, "Test initialization of member captureHeight!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFImageType()== mitk::ToFImageWriter::ToFImageType3D, "Test initialization of member ToFImageType!");

  //set member parameter and test again
  unsigned int dimX = 255;
  unsigned int dimY = 188;
  std::string distanceImageFileName("distImg.pic");
  std::string amplitudeImageFileName("amplImg.pic");
  std::string intensityImageFileName("intImg.pic");
  std::string rgbImageFileName("rgbImg.pic");
  std::string fileExtension(".test");
  bool distanceImageSelected = false;
  bool amplitudeImageSelected = false;
  bool intensityImageSelected = false;
  bool rgbImageSelected = false;

  tofWriter->SetToFCaptureWidth(dimX);
  tofWriter->SetToFCaptureHeight(dimY);
  tofWriter->SetDistanceImageFileName(distanceImageFileName);
  tofWriter->SetAmplitudeImageFileName(amplitudeImageFileName);
  tofWriter->SetIntensityImageFileName(intensityImageFileName);
  tofWriter->SetRGBImageFileName(rgbImageFileName);
  tofWriter->SetExtension(fileExtension);
  tofWriter->SetDistanceImageSelected(distanceImageSelected);
  tofWriter->SetAmplitudeImageSelected(amplitudeImageSelected);
  tofWriter->SetIntensityImageSelected(intensityImageSelected);
  tofWriter->SetRGBImageSelected(rgbImageSelected);
  tofWriter->SetToFImageType(mitk::ToFImageWriter::ToFImageType2DPlusT);

  MITK_TEST_CONDITION_REQUIRED(distanceImageFileName==tofWriter->GetDistanceImageFileName(), "Testing set/get distance image file name");
  MITK_TEST_CONDITION_REQUIRED(amplitudeImageFileName==tofWriter->GetAmplitudeImageFileName(), "Testing set/get amplitude image file name");
  MITK_TEST_CONDITION_REQUIRED(intensityImageFileName==tofWriter->GetIntensityImageFileName(), "Testing set/get intensity image file name");
  MITK_TEST_CONDITION_REQUIRED(rgbImageFileName==tofWriter->GetRGBImageFileName(), "Testing set/get rgb image file name");
  MITK_TEST_CONDITION_REQUIRED(dimX==tofWriter->GetToFCaptureWidth(), "Testing set/get CaptureWidth");
  MITK_TEST_CONDITION_REQUIRED(dimY==tofWriter->GetToFCaptureHeight(), "Testing set/get CaptureHeight");
  MITK_TEST_CONDITION_REQUIRED(distanceImageSelected==tofWriter->GetDistanceImageSelected(), "Testing set/get distance image selection");
  MITK_TEST_CONDITION_REQUIRED(amplitudeImageSelected==tofWriter->GetAmplitudeImageSelected(), "Testing set/get amplitude image selection");
  MITK_TEST_CONDITION_REQUIRED(intensityImageSelected==tofWriter->GetIntensityImageSelected(), "Testing set/get intensity image selection");
  MITK_TEST_CONDITION_REQUIRED(rgbImageSelected==tofWriter->GetRGBImageSelected(), "Testing set/get rgb image selection");
  MITK_TEST_CONDITION_REQUIRED(fileExtension==tofWriter->GetExtension(), "Testing set/get file extension");
  MITK_TEST_CONDITION_REQUIRED(mitk::ToFImageWriter::ToFImageType2DPlusT==tofWriter->GetToFImageType(), "Testing set/get ToFImageType");

  MITK_TEST_END();
}
Example #3
0
static bool saveMazeFile() {
	char filename[MAX_PATH];
	memset(filename, 0, MAX_PATH);
	snprintf(filename, MAX_PATH, "%s", lastFilename.c_str());

	OPENFILENAME ofn;
	ZeroMemory(&ofn, sizeof(ofn));

	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = nullptr;
	ofn.lpstrFile = filename;
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrFilter = "Mazes (*.pmz)\0*.pmz\0All files (*.*)\0*.*\0";
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = nullptr;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = nullptr;
	ofn.Flags |= OFN_NOCHANGEDIR;

    if (GetSaveFileName(&ofn)) {
        if (strlen(fileExtension(filename)) == 0) {
			size_t namesize = strlen(filename);
			filename[namesize] = '.';
			filename[namesize + 1] = 'p';
			filename[namesize + 2] = 'm';
			filename[namesize + 3] = 'z';
			filename[namesize + 4] = '\0';
        }
		lastFilename = filename;
        saveMaze(filename, mainMaze.get());
        return true;
    }
    return false;
}
Example #4
0
bool CanvasExporterPS::write()
{
    QString format("PostScript (%1)");

    int vtkPSFormat = -1;
    if (outputFormat() == format.arg("PS"))
        vtkPSFormat = vtkGL2PSExporter::PS_FILE;
    else if (outputFormat() == format.arg("EPS"))
        vtkPSFormat = vtkGL2PSExporter::EPS_FILE;
    else if (outputFormat() == format.arg("PDF"))
        vtkPSFormat = vtkGL2PSExporter::PDF_FILE;
    else if (outputFormat() == format.arg("TEX"))
        vtkPSFormat = vtkGL2PSExporter::TEX_FILE;
    else if (outputFormat() == format.arg("SVG"))
        vtkPSFormat = vtkGL2PSExporter::SVG_FILE;
    else
        return false;

    // vtkGL2PSExporter always appends a file extensions, so we should cut it if it already exists
    QString fileName = outputFileName();
    QString ext = fileExtension();
    QFileInfo info(fileName);
    if (info.suffix().toLower() == ext)
    {
        fileName.truncate(fileName.length() - ext.length() - 1); // cut ".EXT"
    }

    m_exporter->SetFilePrefix(fileName.toUtf8().data());
    m_exporter->SetFileFormat(vtkPSFormat);
    m_exporter->SetRenderWindow(renderWindow());
    m_exporter->Write();

    return true;
}
Example #5
0
/*  Determines whether the specified file name is considered to be a header
 *  file for the purposes of determining whether enclosed tags are global or
 *  static.
 */
extern boolean isIncludeFile (const char *const fileName)
{
	boolean result = FALSE;
	const char *const extension = fileExtension (fileName);
	if (Option.headerExt != NULL)
		result = stringListExtensionMatched (Option.headerExt, extension);
	return result;
}
Example #6
0
/*!
  If the \a node has a URL, return the URL as the file name.
  Otherwise, construct the file name from the fileBase() and
  the fileExtension(), and return the constructed name.
 */
QString PageGenerator::fileName(const Node* node) const
{
    if (!node->url().isEmpty())
        return node->url();

    QString name = fileBase(node);
    name += QLatin1Char('.');
    name += fileExtension(node);
    return name;
}
GlfImageSharedPtr
GlfImageRegistry::_ConstructImage(std::string const & filename)
{
    static GlfImageSharedPtr NULL_IMAGE;

    // Lookup the plug-in type name based on the filename.
    TfToken fileExtension(ArGetResolver().GetExtension(filename));

    TfType const & pluginType = _typeMap->Find(fileExtension);

    if (!pluginType) {
        // Unknown prim type.
        TF_DEBUG(GLF_DEBUG_TEXTURE_IMAGE_PLUGINS).Msg(
                "[PluginLoad] Unknown image type '%s'\n",
                fileExtension.GetText());
        return NULL_IMAGE;
    }

    PlugRegistry& plugReg = PlugRegistry::GetInstance();
    PlugPluginPtr plugin = plugReg.GetPluginForType(pluginType);
    if (!plugin || !plugin->Load()) {
        TF_CODING_ERROR("[PluginLoad] PlugPlugin could not be loaded for "
                "TfType '%s'\n",
                pluginType.GetTypeName().c_str());
        return NULL_IMAGE;
    }

    GlfImageFactoryBase* factory = pluginType.GetFactory<GlfImageFactoryBase>();
    if (!factory) {
        TF_CODING_ERROR("[PluginLoad] Cannot manufacture type '%s' "
                "for image type '%s'\n",
                pluginType.GetTypeName().c_str(),
                fileExtension.GetText());

        return NULL_IMAGE;
    }

    GlfImageSharedPtr instance = factory->New();
    if (!instance) {
        TF_CODING_ERROR("[PluginLoad] Cannot construct instance of type '%s' "
                "for image type '%s'\n",
                pluginType.GetTypeName().c_str(),
                fileExtension.GetText());
        return NULL_IMAGE;
    }

    TF_DEBUG(GLF_DEBUG_TEXTURE_IMAGE_PLUGINS).Msg(
    	        "[PluginLoad] Loaded plugin '%s' for image type '%s'\n",
                pluginType.GetTypeName().c_str(),
                fileExtension.GetText());

    return instance;
}
Example #8
0
void Soup::addToSoup(vector<string> lines, string filename)
{
  //printf("Adding some lines from %s to the soup.\n",filename.c_str());

  int loc = filename.rfind( ".");
  string fileExtension(filename, loc, filename.size()-loc);

  if(fileExtension == ".pdb")
    interpretatePDBLines(lines,filename);
  else if(fileExtension == ".mol2")
    interpretateMOL2Lines(lines,filename);
  else
    {
      printf("Unknown file extension: '%s'\n",fileExtension.c_str());
      exit(0);
    }
 
}
// static
QList<Mixxx::SoundSourceProviderRegistration>
SoundSourceProxy::findSoundSourceProviderRegistrations(
        const QUrl& url) {
    QString fileExtension(Mixxx::SoundSource::getFileExtensionFromUrl(url));
    if (fileExtension.isEmpty()) {
        qWarning() << "Unknown file type:" << url.toString();
        return QList<Mixxx::SoundSourceProviderRegistration>();
    }

    QList<Mixxx::SoundSourceProviderRegistration> registrationsForFileExtension(
            s_soundSourceProviders.getRegistrationsForFileExtension(
                    fileExtension));
    if (registrationsForFileExtension.isEmpty()) {
        qWarning() << "Unsupported file type:" << url.toString();
    }

    return registrationsForFileExtension;
}
Example #10
0
File: parse.c Project: FelikZ/ctags
extern langType getFileLanguage (const char *const fileName)
{
	langType language = Option.language;
	if (language == LANG_AUTO)
	{
		language = getExtensionLanguage (fileExtension (fileName));
		if (language == LANG_IGNORE)
			language = getPatternLanguage (fileName);
#ifdef SYS_INTERPRETER
		if (language == LANG_IGNORE)
		{
			fileStatus *status = eStat (fileName);
			if (status->isExecutable)
				language = getInterpreterLanguage (fileName);
		}
#endif
	}
	return language;
}
Example #11
0
GlfTextureFactoryBase*
GlfTextureRegistry::_GetTextureFactory(const TfToken &filename)
{
    // Lookup the plug-in type name based on the file extension.
    TfToken fileExtension(TfStringGetSuffix(filename));

    TfType pluginType = _typeMap->Find(fileExtension);
    if (!pluginType) {
        // Unknown type.  Try the wildcard.
        pluginType = _typeMap->Find(TfToken("*"));
        if (!pluginType) {
            TF_DEBUG(GLF_DEBUG_TEXTURE_PLUGINS).Msg(
                    "[PluginLoad] Unknown texture type '%s'\n",
                    fileExtension.GetText());
            return nullptr;
        }
    }

    PlugRegistry& plugReg = PlugRegistry::GetInstance();
    PlugPluginPtr plugin = plugReg.GetPluginForType(pluginType);
    if (!plugin || !plugin->Load()) {
        TF_CODING_ERROR("[PluginLoad] PlugPlugin could not be loaded for "
                        "TfType '%s'\n",
                        pluginType.GetTypeName().c_str());
        return nullptr;
    }

    TF_DEBUG(GLF_DEBUG_TEXTURE_IMAGE_PLUGINS).Msg(
    	        "[PluginLoad] Loaded plugin '%s' for texture type '%s'\n",
                pluginType.GetTypeName().c_str(),
                fileExtension.GetText());

    if (GlfTextureFactoryBase* factory =
            pluginType.GetFactory<GlfTextureFactoryBase>()) {
        return factory;
    }
    TF_CODING_ERROR("[PluginLoad] Cannot manufacture type '%s' "
                    "for texture type '%s'\n",
                    pluginType.GetTypeName().c_str(),
                    fileExtension.GetText());

    return nullptr;
}
Example #12
0
// static
QList<mixxx::SoundSourceProviderRegistration>
SoundSourceProxy::findSoundSourceProviderRegistrations(
        const QUrl& url) {
    if (url.isEmpty()) {
        // silently ignore empty URLs
        return QList<mixxx::SoundSourceProviderRegistration>();
    }
    QString fileExtension(mixxx::SoundSource::getFileExtensionFromUrl(url));
    if (fileExtension.isEmpty()) {
        kLogger.warning() << "Unknown file type:" << url.toString();
        return QList<mixxx::SoundSourceProviderRegistration>();
    }

    QList<mixxx::SoundSourceProviderRegistration> registrationsForFileExtension(
            s_soundSourceProviders.getRegistrationsForFileExtension(
                    fileExtension));
    if (registrationsForFileExtension.isEmpty()) {
        kLogger.warning() << "Unsupported file type:" << url.toString();
    }

    return registrationsForFileExtension;
}
Example #13
0
void Soup::addToSoup(string filename)
{
  //  printf("Adding contents of %s to the soup.\n",filename.c_str());

  vector<string> lines;
  string line;

  ifstream file(filename.c_str());

  if(!file.is_open())
    {
      printf("File %s not found!\n",filename.c_str());
      exit(0);
    }

  while(!file.eof())
    {
      getline(file, line);
      lines.push_back(line);
    }

  printf("File %s has been read:\n",filename.c_str());
  
  int loc = filename.rfind( ".");
  string fileExtension(filename, loc, filename.size()-loc);
 
  if(fileExtension == ".pdb")
    interpretatePDBLines(lines,filename);
  else if(fileExtension == ".mol2")
    interpretateMOL2Lines(lines,filename);
  else
    {
      printf("Unknown file extension: '%s'\n",fileExtension.c_str());
      exit(0);
    }
}
Example #14
0
static void findBasicTags (void)
{
	const char *line;
	const char *extension = fileExtension (getInputFileName ());
	KeyWord *keywords;

	if (strcmp (extension, "bb") == 0)
		keywords = blitzbasic_keywords;
	else if (strcmp (extension, "pb") == 0)
		keywords = purebasic_keywords;
	else
		keywords = freebasic_keywords;

	while ((line = (const char *) readLineFromInputFile ()) != NULL)
	{
		const char *p = line;
		KeyWord const *kw;

		while (isspace (*p))
			p++;

		/* Empty line? */
		if (!*p)
			continue;

		/* In Basic, keywords always are at the start of the line. */
		for (kw = keywords; kw->token; kw++)
			if (match_keyword (p, kw)) break;

		/* Is it a label? */
		if (strcmp (extension, "bb") == 0)
			match_dot_label (p);
		else
			match_colon_label (p);
	}
}
Example #15
0
void WorldBuilder::buildWorld()
{
	// Load height files
	osg::notify(osg::ALWAYS) << "Reading height file(s)..." << std::endl;
	std::vector<std::string>::iterator it;
	int filenumber = 0;

	for (it = m_heigthFilenames.begin(); it != m_heigthFilenames.end(); ++it) {
		osg::notify(osg::DEBUG_INFO) << "Reading height file: " << ++filenumber << " of " << m_heigthFilenames.size() << std::endl;
		std::string heightFilename = osgDB::findDataFile(*it);

		if (!heightFilename.empty()) {
			osg::ref_ptr<HeightTile> heightTile = new HeightTile();
			heightTile->load(heightFilename);
			m_heightTiles.push_back(heightTile);
		} else {
			osg::notify(osg::WARN) << "Warning: Could not find height data file: " << (*it) << std::endl;
		}
	}

	// Load shape files and populate height files with polygons
	osg::notify(osg::ALWAYS) << "Reading shape file(s)..." << std::endl;
	filenumber = 0;

	for (it = m_shapeFilenames.begin(); it != m_shapeFilenames.end(); ++it) {
		osg::notify(osg::DEBUG_INFO) << "Reading shape file: " << ++filenumber << " of " << m_shapeFilenames.size() << std::endl;
		std::string shapeFilename = osgDB::findDataFile(*it);

		if (!shapeFilename.empty()) {
			osg::ref_ptr<ShapeTile> shapeWorld = new ShapeTile();
			shapeWorld->load(shapeFilename);
			m_shapeTiles.push_back(shapeWorld);
		} else {
			osg::notify(osg::WARN) << "Warning: Could not find shape file: " << (*it) << std::endl;
		}
	}

	// Extract polygons from shape tiles
	osg::notify(osg::ALWAYS) << "Extracting polygons..." << std::endl;
	int tilenumber = 0;
	ShapeWorldVectorIterator shapeIt;

	for (shapeIt = m_shapeTiles.begin(); shapeIt != m_shapeTiles.end(); ++shapeIt) {
		osg::notify(osg::DEBUG_INFO) << "Processed shape tile: " << ++tilenumber << " of " << m_shapeTiles.size() << std::endl;
		osg::ref_ptr<ShapeTile> shapeWorld = (*shapeIt);
		addPolygonsToHeight(shapeWorld->polygons());
	}

	// Update height values for polygons
	osg::notify(osg::ALWAYS) << "Update heights in polygons..." << std::endl;
	tilenumber = 0;
	HeightTileVectorIterator heightIt;

	for (heightIt = m_heightTiles.begin(); heightIt != m_heightTiles.end(); ++heightIt) {
		osg::notify(osg::DEBUG_INFO) << "Update height in tile: " << ++tilenumber << " of " << m_heightTiles.size() << std::endl;
		osg::ref_ptr<HeightTile> heightTile = (*heightIt);
		heightTile->updatePolygonHeight();
	}

	// Use OSG binary format as default
	std::string fileExtension("osgb");
	std::string path = osgDB::getCurrentWorkingDirectory();
	std::string filename("buildings");

	if (!m_outputFilename.empty()) {
		if (osgDB::getLowerCaseFileExtension(m_outputFilename) != "osgb") {
			osg::notify(osg::WARN) << "Warning: Unknown file extension specified. Reverting to .osgb file format." << std::endl;
		}

		filename = osgDB::getStrippedName(m_outputFilename);
		path = osgDB::getFilePath(m_outputFilename);
	}

	// Build complete filename
	std::stringstream completeFilename;
	completeFilename << path;
	completeFilename << osgDB::getNativePathSeparator();
	completeFilename << filename;
	completeFilename << ".";
	completeFilename << fileExtension;
	// Build balanced tree for polygons
	osg::ref_ptr<PolygonTree> polygonTree = new PolygonTree(path, filename);
	polygonTree->setBucketSize(m_maxBuildingsPerFile);
	osg::notify(osg::ALWAYS) << "Build polygon tree..." << std::endl;

	for (heightIt = m_heightTiles.begin(); heightIt != m_heightTiles.end(); ++heightIt) {
		osg::notify(osg::DEBUG_INFO) << "Getting polygons from height tile: " << ++tilenumber << " of " << m_heightTiles.size() << std::endl;
		osg::ref_ptr<HeightTile> heightTile = (*heightIt);
		PolygonVector polygons = heightTile->polygons();

		if (!polygons.empty()) {
			PolygonVectorIterator polygonIt;

			for (polygonIt = polygons.begin(); polygonIt != polygons.end(); ++polygonIt) {
				osg::ref_ptr<Polygon> polygon = (*polygonIt);
				polygonTree->addPolygon(polygon);
			}
		}
	}

	// Add polygons that are outside height tiles to tree
	if (!m_polygonsOutsideTiles.empty()) {
		osg::notify(osg::ALWAYS) << "Polygons outside height tiles: " << m_polygonsOutsideTiles.size() << std::endl;
		PolygonVectorIterator polygonIt;

		for (polygonIt = m_polygonsOutsideTiles.begin(); polygonIt != m_polygonsOutsideTiles.end(); ++polygonIt) {
			osg::ref_ptr<Polygon> polygon = (*polygonIt);
			polygonTree->addPolygon(polygon);
		}
	}

	// Balance polygon tree
	osg::notify(osg::ALWAYS) << "Balancing polygon tree..." << std::endl;
	polygonTree->balance();
	// Create buildings from polygons
	osg::notify(osg::ALWAYS) << "Create buildings from polygon tree..." << std::endl;
	osg::ref_ptr<osg::Group> worldGroup = polygonTree->createBuildingTree();
	// Write model output
	osg::notify(osg::ALWAYS) << "Write models as output..." << std::endl;
	osgDB::writeNodeFile(*worldGroup, completeFilename.str());
	// Export all textures
	osg::notify(osg::ALWAYS) << "Exporting textures..." << std::endl;
	std::stringstream texturePath;
	texturePath << path;
	texturePath << osgDB::getNativePathSeparator();
	texturePath << filename;
	texturePath << "_root";
	TextureLibrary::instance().exportTextures(texturePath.str());
}