void PLYParser::startParsing(std::string path)
{
    if(path.length() == 0)
        importFile( "../plyFiles/dodecahedron.ply" );
    else
        importFile( path );

    objMesh.setParsingStatus();
}
コード例 #2
0
ファイル: FIFImportExport.cpp プロジェクト: 12019/svn.gov.pt
int 
main(int argc, char *argv[]) {
	// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
	FreeImage_Initialise();
#endif // FREEIMAGE_LIB

	// initialize FreeImage error handler

	FreeImage_SetOutputMessage(MyMessageFunc);

	// print version & copyright infos

	cout << "FreeImage " << FreeImage_GetVersion() << "\n";
	cout << FreeImage_GetCopyrightMessage() << "\n\n";

	// Print input formats (including external plugins) known by the library
	fstream importFile("fif_import.csv", ios::out);
	PrintImportFormats(importFile);
	importFile.close();

	// Print output formats (including plugins) known by the library
	// for each export format, supported bitdepths are given
	fstream exportFile("fif_export.csv", ios::out);
	PrintExportFormats(exportFile);
	exportFile.close();

	// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
	FreeImage_DeInitialise();
#endif // FREEIMAGE_LIB

	return 0;

}
コード例 #3
0
ファイル: FileEditionWidget.cpp プロジェクト: Neobot/PC
void FileEditionWidget::setFiles(const QStringList &filenames)
{
	ui->tableWidget->clear();
	ui->tableWidget->setColumnCount(2);
	ui->tableWidget->setRowCount(filenames.count());
	ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
	ui->tableWidget->horizontalHeader()->setSectionResizeMode(FilenamePos, QHeaderView::Stretch);

	int row = 0;
	foreach(const QString& file, filenames)
	{
		QTableWidgetItem* item = new QTableWidgetItem(file);
		ui->tableWidget->setItem(row, FilenamePos, item);

		ButtonWidget* btns = new ButtonWidget(this);
		ui->tableWidget->setCellWidget(row, ButtonsPos, btns);

		_editMapper->setMapping(btns, file);
		_exportMapper->setMapping(btns, file);
		_importMapper->setMapping(btns, file);
		_resetMapper->setMapping(btns, file);

		connect(btns, SIGNAL(editFile()), _editMapper, SLOT(map()));
		connect(btns, SIGNAL(exportFile()), _exportMapper, SLOT(map()));
		connect(btns, SIGNAL(importFile()), _importMapper, SLOT(map()));
		connect(btns, SIGNAL(removeFile()), _resetMapper, SLOT(map()));

		++row;
	}
コード例 #4
0
ファイル: Archive.cpp プロジェクト: sirjuddington/SLADE
// -----------------------------------------------------------------------------
// Imports all files (including subdirectories) from [directory] into the
// archive
// -----------------------------------------------------------------------------
bool Archive::importDir(string_view directory)
{
	// Get a list of all files in the directory
	vector<string> files;
	for (const auto& item : std::filesystem::recursive_directory_iterator{ directory })
		if (item.is_regular_file())
			files.push_back(item.path().string());

	// Go through files
	for (const auto& file : files)
	{
		StrUtil::Path fn{ StrUtil::replace(file, directory, "") }; // Remove directory from entry name

		// Split filename into dir+name
		auto ename = fn.fileName();
		auto edir  = fn.path();

		// Remove beginning \ or / from dir
		if (StrUtil::startsWith(edir, '\\') || StrUtil::startsWith(edir, '/'))
			edir.remove_prefix(1);

		// Add the entry
		auto dir   = createDir(edir);
		auto entry = addNewEntry(ename, dir->numEntries() + 1, dir);

		// Load data
		entry->importFile(file);

		// Set unmodified
		entry->setState(ArchiveEntry::State::Unmodified);
		dir->dirEntry()->setState(ArchiveEntry::State::Unmodified);
	}

	return true;
}
コード例 #5
0
/**
* Runs the import process based on the input file
* or directory given in the constructor
**/
void medAbstractDatabaseImporter::internalRun ( void )
{
    if(!d->file.isEmpty())
        importFile();
    else if ( d->data )
        importData();
}
コード例 #6
0
ファイル: BlankState.cpp プロジェクト: 27sparks/GoldenCheetah
//
// Replace diary window when no ride
//
BlankStateDiaryPage::BlankStateDiaryPage(Context *context) : BlankStatePage(context)
{
    dontShow->setChecked(appsettings->cvalue(context->athlete->cyclist, GC_BLANK_DIARY, false).toBool());
    welcomeTitle->setText(tr("Diary"));
    welcomeText->setText(tr("No ride ?\nLet's start with some data."));

    img->setIcon(QPixmap(":images/diary.png"));
    img->setIconSize(QSize(800,330));

    ShortCut scImport;
    scImport.label = tr("Import files from your disk or usb device");
    scImport.buttonLabel = tr("Import data");
    scImport.buttonIconPath = ":images/mac/download.png";
    QPushButton *importButton = addToShortCuts(scImport);
    connect(importButton, SIGNAL(clicked()), context->mainWindow, SLOT(importFile()));

    ShortCut scDownload;
    scDownload.label = tr("Download from serial device.");
    scDownload.buttonLabel = tr("Download from device");
    scDownload.buttonIconPath = ":images/mac/download.png";
    QPushButton *downloadButton = addToShortCuts(scDownload);
    connect(downloadButton, SIGNAL(clicked()), context->mainWindow, SLOT(downloadRide()));

    canShow_ = !appsettings->cvalue(context->athlete->cyclist, GC_BLANK_DIARY).toBool();
}
コード例 #7
0
int main(int argc,char* argv[])
{
	if(argc < 3)
	{
		printf("Modo de usar:\n ./grep expressao arquivo\n");
		return 0;
	}
    
	char* exp = (char*)malloc(tamanhoaux*sizeof(char));
	strcpy(exp,argv[1]);
	char* contentFile = (char*)malloc(tamTextArquivo*sizeof(char));
	contentFile = importFile(argv[2]);
	Stack* stack = createStack(tamanhoaux);

	if(!VerificacaoPilha(stack,exp))
		printf("Expressão Invalida\n");

	char* newExp;
	newExp = convertExpression(exp);
	printf("Expressão lida: %s\n", newExp);

	State* state = exprestoNdeter(newExp);
	printRightLines(contentFile,argv[2],state);

    return 0;
}
コード例 #8
0
ファイル: main.c プロジェクト: TKV14/suricastat
void launchStatsFile(char *log)
{
	dataList *l = NULL;

	importFile(log, &l);
	stats(l);

	freeDataList(l);
}
コード例 #9
0
ファイル: main.c プロジェクト: TKV14/suricastat
void launchImport(char *log)
{
	dataList *l = NULL;

	importFile(log, &l);
	insertDataList(l);

	freeDataList(l);
}
コード例 #10
0
void Centerline::run()
{
  double t1 = Cpu();
  if (update_needed){
    std::ifstream input;
    //std::string pattern = FixRelativePath(fileName, "./");
    //Msg::StatusBar(true, "Reading TEST '%s'...", pattern.c_str());
    //input.open(pattern.c_str());
    input.open(fileName.c_str());
    if(StatFile(fileName))
      Msg::Fatal("Centerline file '%s' does not exist ", fileName.c_str());
    importFile(fileName);
    buildKdTree();
    update_needed = false;
  }

  if (is_cut) cutMesh();
  else{
    GFace *gf = current->getFaceByTag(1);
    gf->addPhysicalEntity(1);
    current->setPhysicalName("wall", 2, 1);//tag 1
    current->createTopologyFromMesh();
    NV = current->getMaxElementaryNumber(0);
    NE = current->getMaxElementaryNumber(1);
    NF = current->getMaxElementaryNumber(2);
    NR = current->getMaxElementaryNumber(3);
  }

  //identify the boundary edges by looping over all discreteFaces
  std::vector<GEdge*> boundEdges;
  double dist_inlet = 1.e6;
  GEdge *gin = NULL;
  for (int i= 0; i< NF; i++){
    GFace *gf = current->getFaceByTag(i+1);
    std::list<GEdge*> l_edges = gf->edges();
    for(std::list<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); it++){
      std::vector<GEdge*>::iterator ite = std::find(boundEdges.begin(),
                                                    boundEdges.end(), *it);
      if (ite != boundEdges.end()) boundEdges.erase(ite);
      else boundEdges.push_back(*it);
      GVertex *gv = (*it)->getBeginVertex();
      SPoint3 pt(gv->x(), gv->y(), gv->z());
      double dist = pt.distance(ptin);
      if(dist < dist_inlet){
	dist_inlet = dist;
	gin = *it;
      }
    }
  }

  if (is_closed)   createClosedVolume(gin, boundEdges);
  if (is_extruded) extrudeBoundaryLayerWall(gin, boundEdges);

  double t2 = Cpu();
  Msg::Info("Centerline operators computed in %g (s) ",t2-t1);
}
コード例 #11
0
double Centerline::operator() (double x, double y, double z, GEntity *ge)
{

  if (update_needed){
     std::ifstream input;
     input.open(fileName.c_str());
     if(StatFile(fileName))
       Msg::Fatal("Centerline file '%s' does not exist", fileName.c_str());
     importFile(fileName);
     buildKdTree();
     update_needed = false;
   }

   double xyz[3] = {x,y,z};
   //take xyz = closest point on boundary in case we are on the planar in/out faces
   //or in the volume
   bool isCompound = false;
   if(ge){
     if (ge->dim() == 2 && ge->geomType() == GEntity::CompoundSurface) isCompound = true;
     std::list<GFace*> cFaces;
     if (isCompound) cFaces = ((GFaceCompound*)ge)->getCompounds();
     if ( ge->dim() == 3 || (ge->dim() == 2 && ge->geomType() == GEntity::Plane) ||
	  (isCompound && (*cFaces.begin())->geomType() == GEntity::Plane) ){
       const int num_neighbours = 1;
       ANNidx index[num_neighbours];
       ANNdist dist[num_neighbours];
       kdtreeR->annkSearch(xyz, num_neighbours, index, dist);
       ANNpointArray nodesR = kdtreeR->thePoints();
       xyz[0] = nodesR[index[0]][0];
       xyz[1] = nodesR[index[0]][1];
       xyz[2] = nodesR[index[0]][2];
     }
   }

   const int num_neighbours = 1;
   ANNidx index[num_neighbours];
   ANNdist dist[num_neighbours];
   kdtree->annkSearch(xyz, num_neighbours, index, dist);
   double rad = sqrt(dist[0]);

   //double cmax, cmin;
   //SVector3 dirMax,dirMin;
   //cmax = ge->curvatures(SPoint2(u, v),&dirMax, &dirMin, &cmax,&cmin);
   //cmax = ge->curvatureMax(SPoint2(u,v));
   //double radC = 1./cmax;

   double lc = 2*M_PI*rad/nbPoints;

   if(!ge) { return rad;}
   else  return lc;

}
コード例 #12
0
/**
* Runs the import process based on the input file
* or directory given in the constructor
**/
void medAbstractDatabaseImporter::internalRun ( void )
{
    if(!QDir(medStorage::dataLocation()).exists())
    {
        emit showError ( tr ( "Your database path does not exist" ), 5000 );
        emit failure(this);
        return;
    }
    if(!d->file.isEmpty())
        importFile();
    else if ( d->data )
        importData();
}
コード例 #13
0
ファイル: classimport.cpp プロジェクト: Nephos/umbrello
/**
 * Import files.
 * @param fileNames  List of files to import.
 */
bool ClassImport::importFiles(const QStringList& fileNames)
{
    initialize();
    UMLDoc *umldoc = UMLApp::app()->document();
    uint processedFilesCount = 0;
    bool result = true;
    umldoc->setLoading(true);
    foreach (const QString& fileName, fileNames) {
        umldoc->writeToStatusBar(i18n("Importing file: %1 Progress: %2/%3",
                                 fileName, processedFilesCount, fileNames.size()));
        if (!importFile(fileName))
            result = false;
        processedFilesCount++;
    }
コード例 #14
0
Centerline::Centerline(std::string fileName): kdtree(0), kdtreeR(0)
{
  recombine = (CTX::instance()->mesh.recombineAll) || (CTX::instance()->mesh.recombine3DAll);
  nbPoints = 25;
  hLayer = 0.3;
  hSecondLayer = 0.3;
  nbElemLayer = 3;
  nbElemSecondLayer = 0;
  is_cut = 0;
  is_closed = 0;
  is_extruded = 0;

  importFile(fileName);
  buildKdTree();
  update_needed = false;
}
コード例 #15
0
ファイル: spdrimport.cpp プロジェクト: sierdzio/spdr
/*!
  \internal

  Recursively imports a directory specified by \a directoryPath. Internally,
  this method also calls importFile() for every file it encounters.

  \sa importFile
  */
bool SpdrImportPrivate::importDirectory(const QString &directoryPath) const
{
    // Goes through all subfolders, returns only files: briliant!
    QDirIterator it(directoryPath, QDir::NoDotAndDotDot | QDir::Files,
                    QDirIterator::Subdirectories);

    while (it.hasNext()) {
        it.next();

        if (!importFile(it.fileInfo().absoluteFilePath())) {
            return false;
        }
    }

    return true;
}
コード例 #16
0
ファイル: waterwidget.cpp プロジェクト: hanfer/FuTa
WaterWidget::WaterWidget(MapTile *file, QWidget *parent) :
    WoWFileWidget(parent)
  ,adtFile(file)
{
    saveButton = new QPushButton(tr("&Export"),this);
    importButton = new QPushButton(tr("&Import"),this);
    QLabel *label = new QLabel("Water Import/Export more features will be added in future",this);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(label);
    mainLayout->addWidget(saveButton,0,Qt::AlignRight);
    mainLayout->addWidget(importButton,0,Qt::AlignRight);

    connect(saveButton,SIGNAL(clicked()),this,SLOT(exportFile()));
    connect(importButton,SIGNAL(clicked()),this,SLOT(importFile()));

    this->setLayout(mainLayout);
}
コード例 #17
0
	bool enumFiles( const char * inFolder )
	{
		FSFileInfo ctxt ;
		FSTraverser fst ;
		long bDone = fst.getFirstFile(ctxt, inFolder,"*.txt" ); 
		while(!bDone)
		{
			std::string str = ctxt.getFileName();
			std::string strFullPath = inFolder + str ;

			importFile( inFolder, strFullPath.c_str() ) ;

			mCntMailsFound++ ;
			if ( mCntMailsFound >= mCntMaxMails )
				return true ;
				
			bDone = fst.getNextFile(ctxt) ;
		}
		return true ;
	}
コード例 #18
0
bool LessParser::parseImportStatement(TokenList &statement, LessStylesheet &stylesheet) {
  unsigned int directive = 0;

  // parse directives and strip from statement (the statement becomes a valid
  // css import statement.)
  if (statement.size() >= 4 &&
      statement.front().type == Token::PAREN_OPEN) {
    statement.pop_front();
    statement.ltrim();
    
    directive = parseImportDirective(statement.front());
    statement.pop_front();
    statement.ltrim();
    
    while (statement.size() > 0 && statement.front() == ",") {
      statement.pop_front();
      statement.ltrim();
      
      directive |= parseImportDirective(statement.front());
      statement.pop_front();
      statement.ltrim();
    }

    if (statement.size() > 0 &&
        statement.front().type != Token::PAREN_CLOSED) 
      throw new ParseException(statement, ")");
  }

  if (statement.size() > 0 &&
      (statement.front().type == Token::URL ||
       statement.front().type == Token::STRING)) {
    return importFile(statement.front(), stylesheet, directive);
        
  } else
    throw new ParseException(statement, "A string with the file path, "
                             "or an import directive.");
}
コード例 #19
0
ファイル: model.cpp プロジェクト: wpfhtl/octocopter
Model::Model(const QFile& file, const QString& mediaPrefix, QObject *parent) : QObject(parent)
{
    mShaderProgram = 0;
    mAssimpScene = 0;
    mMediaPrefix = mediaPrefix;

    if(!importFile(file)) return;

    // This needs to be unique!
    mMaterialUniformLocation = 2;

    initialize();

    mShaderProgram = new ShaderProgram(this, "shader-model-vertex.c", "", "shader-model-fragment.c");

    mShaderProgram->bindUniformBlockToPoint("Material", mMaterialUniformLocation);

    //program = setupShaders();
    generateVAOsAndUniformBuffer(mAssimpScene);

    //    glEnable(GL_DEPTH_TEST);
    //    glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

    //
    // Uniform Block
    //
    /* superfluous, these are the global matrices we have in glwidget
    glGenBuffers(1,&matricesUniBuffer);
    glBindBuffer(GL_UNIFORM_BUFFER, matricesUniBuffer);
    glBufferData(GL_UNIFORM_BUFFER, MatricesUniBufferSize,NULL,GL_DYNAMIC_DRAW);
    glBindBufferRange(GL_UNIFORM_BUFFER, matricesUniLoc, matricesUniBuffer, 0, MatricesUniBufferSize);	//setUniforms();
    glBindBuffer(GL_UNIFORM_BUFFER,0);
*/
    //glEnable(GL_MULTISAMPLE);

}
コード例 #20
0
ファイル: FileEditionWidget.cpp プロジェクト: Neobot/PC
FileEditionWidget::FileEditionWidget(QWidget *parent) :
	QWidget(parent),
	ui(new Ui::FileEditionWidget),  _askFileContext(None), _gridEditor(nullptr), _propertiesBrowser(nullptr),
    _propertyDialog(nullptr), _plainTextEditor(nullptr), _textDialog(nullptr),
	_nsEditor(nullptr), _nsDialog(nullptr)
{
	ui->setupUi(this);

	_editMapper = new QSignalMapper(this);
    connect(_editMapper, SIGNAL(mapped(QString)), this, SLOT(editFile(QString)));
	connect(ui->tableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(rowDoubleClicked(int)));

	_exportMapper = new QSignalMapper(this);
    connect(_exportMapper, SIGNAL(mapped(QString)), this, SLOT(exportFile(QString)));

	_importMapper = new QSignalMapper(this);
    connect(_importMapper, SIGNAL(mapped(QString)), this, SLOT(importFile(QString)));

	_resetMapper = new QSignalMapper(this);
    connect(_resetMapper, SIGNAL(mapped(QString)), this, SLOT(resetFile(QString)));

    connect(ui->btnImportFile, SIGNAL(clicked()), this, SLOT(importFromDisk()));
    connect(ui->btnNewFile, SIGNAL(clicked()), this, SLOT(newFile()));
}
コード例 #21
0
void chanFileSystemDockWidget::createContextMenu() {

    m_actionArray[CreateFile]->setText("new file");
    connect(m_actionArray[CreateFile], SIGNAL(triggered()),
            this, SLOT(createFile()));

    m_actionArray[CreateFolder]->setText("new folder");
    connect(m_actionArray[CreateFolder], SIGNAL(triggered()),
            this, SLOT(createFolder()));

    m_actionArray[ImportFile]->setText("import file");
    connect(m_actionArray[ImportFile], SIGNAL(triggered()),
            this, SLOT(importFile()));

    m_actionArray[RemoveFile]->setText("remove file");
    connect(m_actionArray[RemoveFile], SIGNAL(triggered()),
            this, SLOT(removeFile()));

    m_actionArray[RemoveFolder]->setText("remove folder");
    connect(m_actionArray[RemoveFolder], SIGNAL(triggered()),
            this, SLOT(removeFolder()));

    m_actionArray[RenameFile]->setText("rename file");
    connect(m_actionArray[RenameFile], SIGNAL(triggered()),
            this, SLOT(renameFile()));

    m_actionArray[RenameFolder]->setText("rename folder");
    connect(m_actionArray[RenameFolder], SIGNAL(triggered()),
            this, SLOT(renameFolder()));

    std::for_each(m_actionArray, m_actionArray + actionArraySize, [this](QAction* item) {
        this->addAction(item);
    });

    setContextMenuPolicy(Qt::ContextMenuPolicy::ActionsContextMenu);
}
コード例 #22
0
ファイル: Mendel.cpp プロジェクト: Redezem/Rosey
Mendel::Mendel(char* inName)
{
	importFile(inName);
}
コード例 #23
0
ファイル: mainwindow.cpp プロジェクト: tangming10000/Tang
void MainWindow::createActions()    /*菜单选项*/
{
    /*文件菜单*/
    openAction = new QAction(tr("打开"),this);
    openAction->setStatusTip(tr("打开新文件"));
    connect(openAction,SIGNAL(triggered()),this,SLOT(openFile()));

    importAction = new QAction(tr("导入"),this);
    importAction->setStatusTip(tr("导入数据"));
    connect(importAction,SIGNAL(triggered()),this,SLOT(importFile()));
    importAction->setDisabled(true);

    sortAction = new QAction(tr("分类数据"),this);
    sortAction->setStatusTip(tr("处理分类数据"));
    connect(sortAction,SIGNAL(triggered()),this,SLOT(sortFile()));
    sortAction->setDisabled(true);

    exitAction = new QAction(tr("退出"),this);
    exitAction->setStatusTip(tr("退出程序"));
    connect(exitAction,SIGNAL(triggered()),this,SLOT(close()));

    /*导入菜单*/
    ebdicAction = new QAction(tr("显示EBDIC码"),this);
    ebdicAction->setStatusTip(tr("显示EBDIC码"));
    connect(ebdicAction,SIGNAL(triggered()),this,SLOT(loadEBDIC()));
    ebdicAction->setDisabled(true);

    reelAction = new QAction(tr("显示卷头"),this);
    reelAction->setStatusTip(tr("显示卷头信息"));
    connect(reelAction,SIGNAL(triggered()),this,SLOT(loadReel()));
    reelAction->setDisabled(true);

    traceAction = new QAction(tr("显示道头"),this);
    traceAction->setStatusTip(tr("显示选定位置道头信息"));
    connect(traceAction,SIGNAL(triggered()),this,SLOT(loadTrace()));
    traceAction->setDisabled(true);

    dataAction = new QAction(tr("地震数据"),this);
    dataAction->setStatusTip(tr("显示选定位置的地震记录"));
    connect(dataAction,SIGNAL(triggered()),this,SLOT(loadData()));
    dataAction->setDisabled(true);

    /*画图菜单*/
    waveAction = new QAction(tr("波形显示"),this);
    waveAction->setStatusTip(tr("波形显示剖面"));
    connect(waveAction,SIGNAL(triggered()),this,SLOT(drawWave()));
    waveAction->setDisabled(true);


    grayAction = new QAction(tr("灰度显示"),this);
    grayAction->setStatusTip(tr("显示灰度图像"));
    connect(grayAction,SIGNAL(triggered()),this,SLOT(drawGray()));
    grayAction->setDisabled(true);

    colorAction = new QAction(tr("彩色显示"),this);
    colorAction->setStatusTip(tr("显示彩色图像"));
    connect(colorAction,SIGNAL(triggered()),this,SLOT(drawColor()));
    colorAction->setDisabled(true);

    //操作openGL图像
    bigAction = new QAction(tr("放大"),this);
    bigAction->setStatusTip(tr("放大图像"));
    connect(bigAction,SIGNAL(triggered()),this,SLOT(bigger()));
    bigAction->setDisabled(true);

    littleAction = new QAction(tr("缩小"),this);
    littleAction->setStatusTip(tr("缩小图像"));
    connect(littleAction,SIGNAL(triggered()),this,SLOT(little()));
    littleAction->setDisabled(true);

    moveleftAction = new QAction(tr("左移"),this);
    moveleftAction->setStatusTip(tr("左移图像"));
    connect(moveleftAction,SIGNAL(triggered()),this,SLOT(moveleft()));
    moveleftAction->setDisabled(true);

    moverightAction = new QAction(tr("右移"),this);
    moverightAction->setStatusTip(tr("图像右移"));
    connect(moverightAction,SIGNAL(triggered()),this,SLOT(moveright()));
    moverightAction->setDisabled(true);

    moveupAction = new QAction(tr("上移"),this);
    moveupAction->setStatusTip(tr("上移图像"));
    connect(moveupAction,SIGNAL(triggered()),this,SLOT(moveup()));
    moveupAction->setDisabled(true);

    movedownAction = new QAction(tr("下移"),this);
    movedownAction->setStatusTip(tr("下移图像"));
    connect(movedownAction,SIGNAL(triggered()),this,SLOT(movedown()));
    movedownAction->setDisabled(true);

    moveMouseAction = new QAction(tr("移动"),this);
    moveMouseAction->setStatusTip(tr("使用鼠标移动图像"));
    connect(moveMouseAction,SIGNAL(triggered()),this,SLOT(moveMouse()));
    moveMouseAction->setDisabled(true);

    rotateMouseAction = new QAction(tr("旋转"),this);
    rotateMouseAction->setStatusTip(tr("旋转图像"));
    connect(rotateMouseAction,SIGNAL(triggered()),this,SLOT(rotateMouse()));
    rotateMouseAction->setDisabled(true);

    nextSliceAction = new QAction(tr("下一条剖面"),this);
    nextSliceAction->setStatusTip(tr("选择下一条剖面"));
    connect(nextSliceAction,SIGNAL(triggered()),this,SLOT(nextSlice()));
    nextSliceAction->setDisabled(true);

    preSliceAction = new QAction(tr("上一条剖面"),this);
    preSliceAction->setStatusTip(tr("选择上一条剖面"));
    connect(preSliceAction,SIGNAL(triggered()),this,SLOT(preSlice()));
    preSliceAction->setDisabled(true);

    drawGridAction = new QAction(tr("关闭网格"),this);
    drawGridAction->setStatusTip(tr("打开/关闭剖面图像上的网格"));
    connect(drawGridAction,SIGNAL(triggered()),this,SLOT(drawGrid()));
    drawGridAction->setDisabled(true);
}
コード例 #24
0
ファイル: mainwindow.cpp プロジェクト: stijnvermeir/mtgcards
void MainWindow::importDeckFromXML()
{
	QStringList filenames = QFileDialog::getOpenFileNames(0, "Import decks from xml", QDir::homePath(), "Decks (*.deck)");
	if (!filenames.empty())
	{
		bool yesToAll = false;
		bool noToAll = false;
		QStringList decksWithIssues;
		for (const QString& filename : filenames)
		{
			QStringList errors;
			QFile importFile(filename);
			if (importFile.open(QIODevice::ReadOnly | QIODevice::Text))
			{
				QFileInfo fileInfo(filename);
				QString newFilename = Settings::instance().getDecksDir() + QDir::separator() + fileInfo.baseName() + ".deck";
				if (QFileInfo(newFilename).exists())
				{
					errors << ("Deck '" + fileInfo.baseName() + "' already exists");
				}
				Deck deck;
				deck.setActive(false);
				QXmlStreamReader xml(&importFile);
				while (!xml.atEnd())
				{
					xml.readNext();
                    if (xml.isStartElement() && xml.name().compare(QString("card")) == 0)
					{
						QString set = xml.attributes().value("edition").toString();
						int qty = xml.attributes().value("deck").toInt();
						int sb = xml.attributes().value("sb").toInt();
						QString name = xml.readElementText();
						if (name.contains("/"))
						{
							name = name.split("/").first();
						}
						int dataRowIndex = mtg::CardData::instance().findRowFast(set, name);
						if (dataRowIndex != -1)
						{
							deck.setQuantity(dataRowIndex, qty);
							deck.setSideboard(dataRowIndex, sb);
						}
						else
						{
							errors << (set + " " + name + " not found");
						}
					}
					if (xml.hasError())
					{
						errors << xml.errorString();
					}
				}

				bool ok = true;
				if (!errors.empty())
				{
					decksWithIssues << fileInfo.baseName();
					if (!yesToAll && !noToAll)
					{
						QMessageBox msgBox;
						msgBox.setWindowTitle("Issues");
						msgBox.setText("There were some issues importing deck <i>" + fileInfo.baseName() + "</i>. Do you want to continue to import this deck?");
						msgBox.setInformativeText("See details to see the issues.");
						msgBox.setDetailedText(errors.join("\n"));
						msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::YesToAll | QMessageBox::NoToAll);
						msgBox.setDefaultButton(QMessageBox::NoToAll);
						msgBox.setIcon(QMessageBox::Warning);
						int ret = msgBox.exec();
						if (ret == QMessageBox::No)
						{
							ok = false;
						}
						if (ret == QMessageBox::NoToAll)
						{
							noToAll = true;
						}
						if (ret == QMessageBox::YesToAll)
						{
							yesToAll = true;
						}
					}
					if (noToAll)
					{
						ok = false;
					}
				}

				if (ok)
				{
					deck.save(newFilename);
					deckWindow_.openDeck(newFilename);
				}
			}
		}
		if (!decksWithIssues.empty())
		{
			QMessageBox msgBox;
			msgBox.setWindowTitle("Decks with issues");
			msgBox.setText("There were some decks with import issues.");
			msgBox.setInformativeText("See details to see which decks had issues.");
			msgBox.setDetailedText(decksWithIssues.join("\n"));
			msgBox.setStandardButtons(QMessageBox::Ok);
			msgBox.setDefaultButton(QMessageBox::Ok);
			msgBox.setIcon(QMessageBox::Warning);
			msgBox.exec();
		}
		else
		{
			QMessageBox::information(0, "Success", "All decks were imported successfully.");
		}
	}
}
コード例 #25
0
ファイル: mainwindow.cpp プロジェクト: stijnvermeir/mtgcards
void MainWindow::importDeckFromText()
{
	QStringList filenames = QFileDialog::getOpenFileNames(0, "Import decks from text", QDir::homePath(), "Decks (*.txt)");
	QString set = QInputDialog::getText(this, "Enter Set Code", "Set Code");
	if (!filenames.empty())
	{
		bool yesToAll = false;
		bool noToAll = false;
		QStringList decksWithIssues;
		for (const QString& filename : filenames)
		{
			QStringList errors;
			QFile importFile(filename);
			if (importFile.open(QIODevice::ReadOnly | QIODevice::Text))
			{
				QFileInfo fileInfo(filename);
				QString newFilename = Settings::instance().getDecksDir() + QDir::separator() + fileInfo.baseName() + ".deck";
				if (QFileInfo(newFilename).exists())
				{
					errors << ("Deck '" + fileInfo.baseName() + "' already exists");
				}
				Deck deck;
				deck.setActive(false);
				QStringList lines;
				QTextStream in(&importFile);
				while (!in.atEnd())
				{
					lines << in.readLine();
				}
				importFile.close();

				for (int i = 0; i < lines.size(); ++i)
				{
					QTextStream stream(&lines[i]);
					int amount;
					stream >> amount;
					QString name = stream.readAll().trimmed();
					qDebug() << "Amount" << amount;
					qDebug() << "Name" << name;
					int dataRowIndex = mtg::CardData::instance().findRowFast(set, name);
					if (dataRowIndex != -1)
					{
						deck.setQuantity(dataRowIndex, amount);
					}
					else
					{
						errors << (set + " " + name + " not found");
					}
				}

				bool ok = true;
				if (!errors.empty())
				{
					decksWithIssues << fileInfo.baseName();
					if (!yesToAll && !noToAll)
					{
						QMessageBox msgBox;
						msgBox.setWindowTitle("Issues");
						msgBox.setText("There were some issues importing deck <i>" + fileInfo.baseName() + "</i>. Do you want to continue to import this deck?");
						msgBox.setInformativeText("See details to see the issues.");
						msgBox.setDetailedText(errors.join("\n"));
						msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::YesToAll | QMessageBox::NoToAll);
						msgBox.setDefaultButton(QMessageBox::NoToAll);
						msgBox.setIcon(QMessageBox::Warning);
						int ret = msgBox.exec();
						if (ret == QMessageBox::No)
						{
							ok = false;
						}
						if (ret == QMessageBox::NoToAll)
						{
							noToAll = true;
						}
						if (ret == QMessageBox::YesToAll)
						{
							yesToAll = true;
						}
					}
					if (noToAll)
					{
						ok = false;
					}
				}

				if (ok)
				{
					deck.save(newFilename);
					deckWindow_.openDeck(newFilename);
				}
			}
		}
コード例 #26
0
ファイル: mainwindow.cpp プロジェクト: stijnvermeir/mtgcards
void MainWindow::importCollection()
{
	QString filename = QFileDialog::getOpenFileName(0, "Import collection from csv", QDir::homePath(), "CSV (*.csv)");
	if (!filename.isNull())
	{
		QFile importFile(filename);
		if (importFile.open(QIODevice::ReadOnly | QIODevice::Text))
		{
			QStringList lines;
			QTextStream in(&importFile);
			while (!in.atEnd())
			{
				lines << in.readLine();
			}
			importFile.close();

			QSqlDatabase db = mtg::Collection::instance().getConnection();
			db.transaction();

			QProgressDialog progress("Importing ...", "Cancel", 0, lines.size());
			progress.setWindowModality(Qt::WindowModal);
			QStringList errors;
			for (int i = 0; i < lines.size(); ++i)
			{
				QStringList splitLine = lines[i].split(";");
				if (splitLine.size() >= 3)
				{
					QString set = splitLine[0];
					QString name = splitLine[1];
					if (name.contains("/"))
					{
						name = name.split("/").first();
					}
					int qty = splitLine[2].toInt();
					int dataRowIndex = mtg::CardData::instance().findRowFast(set, name);
					if (dataRowIndex != -1)
					{
						int current = mtg::Collection::instance().getQuantity(dataRowIndex);
						mtg::Collection::instance().setQuantity(dataRowIndex, current + qty);
					}
					else
					{
						errors << (set + " " + name + " not found");
					}
				}
				else
				{
					errors << ("Line " + QString::number(i+1) + " is invalid");
				}
				progress.setValue(i);
				if (progress.wasCanceled())
				{
					db.rollback();
					break;
				}
			}
			progress.setValue(lines.size());
			if (!progress.wasCanceled())
			{
				if (errors.empty())
				{
					db.commit();
				}
				else
				{
					QMessageBox msgBox;
					msgBox.setWindowTitle("Issues");
					msgBox.setText("Some cards could not be imported. Do you want to continue with the import?");
					msgBox.setInformativeText("See details to know which cards could not be imported.");
					msgBox.setDetailedText(errors.join("\n"));
					msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
					msgBox.setDefaultButton(QMessageBox::Yes);
					msgBox.setIcon(QMessageBox::Warning);
					int ret = msgBox.exec();
					if (ret == QMessageBox::Yes)
					{
						db.commit();
					}
					else
					{
						db.rollback();
					}
				}
			}
			collectionWindow_.reload();
		}
	}
}
コード例 #27
0
ファイル: main.c プロジェクト: sacanepa/tp_laboratorio_1
int main()
{
    int r,i;
    int *auxInt = malloc(sizeof(int));
    float *auxFloat = malloc(sizeof(float));
    int *auxIndex = malloc(sizeof(int));
    int choice;
    Employee *pEmployee = malloc(sizeof(Employee));
    Employee *pEmployee2 = malloc(sizeof(Employee));

    ArrayList *nomina;
    ArrayList *nominaCloned;
    ArrayList *nominaFilter;

    nomina = al_newArrayList();

    r = importFile(nomina,"Nomina.txt");

    do
    {
        choice = menu("\n*************** TP 4 - CANEPA ***************\n\n"
                  "1- Agregar empleado\n2- Modificar empleado\n"
                  "3- Borrar empleado\n4- Listar\n"
                  "5- PUSH empleado\n6- Listar por salario\n"
                  "7- Listar por Nombre\n8- Filtrar salarios\n"
                  "9- Borrar todos\n10- Guardar y Salir\n");

        switch(choice)
        {
        case 1:
            system("cls");

            pEmployee = newEmployee();
            pEmployee2 = searchEmployee(nomina,auxIndex,pEmployee->id);

            if(pEmployee2 == NULL)
            {
                nomina->add(nomina,pEmployee);
            } else {
                printf("Error. El legajo ya existe.");
                printEmployee(pEmployee2,*auxIndex);
            }

            r = nomina->len(nomina);
            printf("Cantidad de empleados: %d\n\n",r);

            system("pause");
            break;

        case 2:
            system("cls");
            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }
            getInt(auxInt,"Ingrese el legajo a editar: ","ERROR",1, 99999999);
            pEmployee = searchEmployee(nomina,auxIndex,*auxInt);

            if(pEmployee == NULL)
            {
                printf("El legajo no existe.");
            } else {
                pEmployee2 = editEmployee(pEmployee);
                printf("Valor Original:\nPosicion: %d\tLegajo: %d\tNombre:%s\tSalario:%.2f\tSector: %d\n\n",*auxIndex,pEmployee->id,pEmployee->name,pEmployee->salary,pEmployee->sector);
                printf("Nuevo valor:   \nPosicion: %d\tLegajo: %d\tNombre:%s\tSalario:%.2f\tSector: %d\n\n",*auxIndex,pEmployee2->id,pEmployee2->name,pEmployee2->salary,pEmployee2->sector);

                if(validaDecision("Confirma modificacion? S/N ")==0)
                    nomina->set(nomina,*auxIndex,pEmployee2);
            }

            system("pause");
            break;

        case 3:
            system("cls");
            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }

            getInt(auxInt,"Ingrese el legajo a eliminar: ","ERROR",1, 99999999);
            pEmployee = searchEmployee(nomina,auxIndex,*auxInt);

            if(pEmployee == NULL)
            {
                printf("El legajo no existe.");
            } else {

                printf("Se eliminira:\nPosicion: %d\tLegajo: %d\tNombre:%s\tSalario:%.2f\tSector: %d\n\n",*auxIndex,pEmployee->id,pEmployee->name,pEmployee->salary,pEmployee->sector);

                if(validaDecision("Confirma eliminacion? S/N ")==0)
                    nomina->pop(nomina,*auxIndex);
            }

            r = nomina->len(nomina);
            printf("Cantidad de empleados: %d\n\n",r);

            system("pause");
            break;

        case 4:
            system("cls");

            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }

            Employee *pEmployeeOr = malloc(sizeof(Employee));
            for(i=0;i<nomina->size;i++)
            {
                pEmployeeOr = nomina->get(nomina,i);
                printEmployee(pEmployeeOr,i);
            }

            r = nomina->len(nomina);
            printf("Cantidad de empleados: %d\n\n",r);

            system("pause");
            break;

        case 5:
            system("cls");
            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }

            pEmployee = newEmployee();

            getInt(auxInt,"\nIngrese la posicion donde desea ingresar: ","ERROR",0, nomina->size);

            nomina->push(nomina,*auxInt,pEmployee);
            r = nomina->len(nomina);
            printf("\nCantidad de empleados: %d\n\n",r);

            system("pause");
            break;

        case 6:
            system("cls");
            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }

            getInt(auxInt,"\n1: Ascendente\n0: Descendente\n\nElija el orden: ","ERROR",0, 1);
            nominaCloned = nomina->clone(nomina);

            r = nomina->containsAll(nomina,nominaCloned);
            if(r != 0)
            {
                for(i=0;i<nominaCloned->size;i++)
                {
                    pEmployee = nominaCloned->get(nominaCloned,i);
                    printEmployee(pEmployee,i);
                }

            }

            r = nomina->len(nomina);
            printf("Cantidad de empleados: %d\n\n",r);

            system("pause");

            nominaCloned->deleteArrayList(nominaCloned);

            break;
        case 7:
            system("cls");
            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }

            getInt(auxInt,"\n1: Ascendente\n0: Descendente\n\nElija el orden: ","ERROR",0, 1);
            nominaCloned = nomina->clone(nomina);
            r = nominaCloned->sort(nominaCloned,compareEmployeeName,*auxInt);

            r = nomina->containsAll(nomina,nominaCloned);
            if(r != 0)
            {
                for(i=0;i<nominaCloned->size;i++)
                {
                    pEmployee = nominaCloned->get(nominaCloned,i);
                    printEmployee(pEmployee,i);
                }

            }

            r = nomina->len(nomina);
            printf("Cantidad de empleados: %d\n\n",r);

            system("pause");

            nominaCloned->deleteArrayList(nominaCloned);

            break;

        case 8:
            system("cls");
            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }

            getFloat(auxFloat,"\nSalarios mayores a:","ERROR",1, 99999999);
            nominaCloned = nomina->clone(nomina);
            nominaCloned->sort(nominaCloned,compareEmployee,0); //sort descendente por salario

            r = nomina->containsAll(nomina,nominaCloned);
            *auxInt = -1;
            if(r != 0)
            {
                for(i=0;i<nominaCloned->size;i++)
                {
                    pEmployee = nominaCloned->get(nominaCloned,i);
                    if(pEmployee->salary >= *auxFloat)
                    {
                        *auxInt = i;
                    }
                }
            }

            if(*auxInt >= 0)
            {
                nominaFilter = nominaCloned->subList(nominaCloned,0,*auxInt);
                for(i=0;i<nominaFilter->size;i++)
                {
                    pEmployee = nominaFilter->get(nominaFilter,i);
                    printEmployee(pEmployee,i);
                }
            }
            r = nominaFilter->len(nominaFilter);
            printf("Cantidad de empleados con salario mayor a %.2f: %d\n\n",*auxFloat,r);
            system("pause");

            nominaCloned->deleteArrayList(nominaCloned);
            nominaFilter->deleteArrayList(nominaFilter);

            break;

        case 9:
            system("cls");
            if(nomina->isEmpty(nomina) != 0)
            {
                printf("Error. Primero ingrese empleados.");
                break;
            }

            nomina->clear(nomina);
            system("pause");
            break;

        case 10:
            system("cls");
            createTxt(nomina);

            nomina->deleteArrayList(nomina);

            break;

        default:
            system("cls");
            printf("\nOpcion invalida. Reingrese.\n");
            system("pause");
            break;
        }
        system("cls");
    } while (choice != 10);

    return 0;
}
コード例 #28
0
ファイル: main.c プロジェクト: mas2ao/trabORD_1
int main(int argc, char** argv) {
    
    int tamTotal, i;
    tamTotal = QUANT_INI;
    
    liPrimCod *primCod[tamTotal];
    for (i=0; i<tamTotal; i++){
        primCod[i] = (liPrimCod*) malloc(sizeof(liPrimCod));
    }
    
    tsecNome *secNome[tamTotal];
    for (i=0; i<tamTotal; i++){
        secNome[i] = (tsecNome*) malloc(sizeof(tsecNome));
    }
    
    tsecCurso *secCurso[tamTotal];
    for (i=0; i<tamTotal; i++){
        secCurso[i] = (tsecCurso*) malloc(sizeof(tsecCurso));
    }
    
//    char *listaNomes[tamTotal];
//    for (i=0; i<tamTotal; i++){
//        listaNomes[i] = (char*) malloc(sizeof(char)*MAX_REC_SIZE);
//    }
    
    tliNome *liNome[tamTotal];
    for (i=0; i<tamTotal; i++){
        liNome[i] = (tliNome*) malloc(sizeof(tliNome));
    }
    
//    int *chaveSecNome[tamTotal];
//    for (i=0; i<tamTotal; i++){
//        chaveSecNome[i] = (int*) malloc(sizeof(int));
//    }
    
    importFile("dados.txt");                    //importa dados - ok
    
    criaChavePrimCod(primCod, tamTotal);         //cria chave primaria(CODIGO) - ok
    criaChaveSecNome(primCod, secNome, tamTotal);             //cria chave secundaria(NOTA) - ok
    criaChaveSecCurso(primCod, secCurso, tamTotal);           //cria chave secundaria(CURSO) - ok
    
    
    
//    for (i=0; i<tamTotal; i++){       //imprime sem ordenadar
//        printf("%d  => %d | %d\n", i, indexPrim[i][0], indexPrim[i][1]);
//    }
//    printf("\n--------------------------------------\n");
    
    insertionSort(primCod, tamTotal);                 //ordena chave primaria(codigo) - ok
    criaIndicePrimario(primCod, tamTotal);            //cria arquivo indice primario(ARQUIVO) - ok
    insertionSortNome(secNome, tamTotal);             //ordena chave secundaria(nome) - ok
    insertionSortCurso(secCurso, tamTotal);             //ordena chave secundaria(curso) - ok
   
    criaIndiceSecNome(liNome, secNome, tamTotal);
    
//    criaListaNomes(indexPrim, listaNomes, tamTotal);
//    insertionSortString(listaNomes, tamTotal);
//    criaIndiceSecAluno(chavePrim, listaNomes, chaveSecNome, tamTotal);
    

    
//    criaMatSecAluno(indexSecNome, tamTotal);
    
//    for (i=0; i<tamTotal; i++){       //imprime apos ordenado
//        printf("%d  => %d | %d\n", i, indexPrim[i][0], indexPrim[i][1]);
//    }
    
    
//    FILE *teste;
//    char dado;
    
//    //verifica calculo offset
//    teste = fopen("reg.txt", "r");
//    fseek(teste, 153, 0);
//    dado = getc(teste);
//    printf("%c", dado);
//    dado = getc(teste);
//    printf("%c", dado);
//    dado = getc(teste);
//    printf("%c", dado);
//    dado = getc(teste);
//    printf("%c", dado);
    
    
    return (EXIT_SUCCESS);
}
コード例 #29
0
void  Centerline::operator() (double x, double y, double z, SMetric3 &metr, GEntity *ge)
{

   if (update_needed){
     std::ifstream input;
     input.open(fileName.c_str());
     if(StatFile(fileName))
       Msg::Fatal("Centerline file '%s' does not exist", fileName.c_str());
     importFile(fileName);
     buildKdTree();
     update_needed = false;
   }


   //take xyz = closest point on boundary in case we are on
   //the planar IN/OUT FACES or in VOLUME
   double xyz[3] = {x,y,z};
   bool onTubularSurface = true;
   double ds = 0.0;
   bool isCompound = (ge->dim() == 2 && ge->geomType() == GEntity::CompoundSurface) ?
     true : false;
   bool onInOutlets = (ge->geomType() == GEntity::Plane) ? true: false;
   std::list<GFace*> cFaces;
   if (isCompound) cFaces = ((GFaceCompound*)ge)->getCompounds();
   if ( ge->dim() == 3 || (ge->dim() == 2 && ge->geomType() == GEntity::Plane) ||
	(isCompound && (*cFaces.begin())->geomType() == GEntity::Plane) ){
     onTubularSurface = false;
   }

   ANNidx index[1];
   ANNdist dist[1];
   kdtreeR->annkSearch(xyz, 1, index, dist);
   if (! onTubularSurface){
     ANNpointArray nodesR = kdtreeR->thePoints();
     ds = sqrt(dist[0]);
     xyz[0] = nodesR[index[0]][0];
     xyz[1] = nodesR[index[0]][1];
     xyz[2] = nodesR[index[0]][2];
   }

   ANNidx index2[2];
   ANNdist dist2[2];
   kdtree->annkSearch(xyz, 2, index2, dist2);
   double radMax = sqrt(dist2[0]);
   ANNpointArray nodes = kdtree->thePoints();
   SVector3  p0(nodes[index2[0]][0], nodes[index2[0]][1], nodes[index2[0]][2]);
   SVector3  p1(nodes[index2[1]][0], nodes[index2[1]][1], nodes[index2[1]][2]);

   //dir_a = direction along the centerline
   //dir_n = normal direction of the disk
   //dir_t = tangential direction of the disk
   SVector3 dir_a = p1-p0; dir_a.normalize();
   SVector3 dir_n(xyz[0]-p0.x(), xyz[1]-p0.y(), xyz[2]-p0.z()); dir_n.normalize();
   SVector3 dir_cross  = crossprod(dir_a,dir_n); dir_cross.normalize();
   // if (ge->dim()==3){
   //   printf("coucou dim ==3 !!!!!!!!!!!!!!! \n");
   //   SVector3 d1,d2,d3;
   //   computeCrossField(x,y,z,d1,d2,d3);
   //   exit(1);
   // }

   //find discrete curvature at closest vertex
   Curvature& curvature = Curvature::getInstance();
   if( !Curvature::valueAlreadyComputed() ) {
     Msg::Info("Need to compute discrete curvature");
     Curvature::typeOfCurvature type = Curvature::RUSIN;
     curvature.computeCurvature(current, type);
   }
   double curv, cMin, cMax;
   SVector3 dMin, dMax;
   int isAbs = 1.0;
   curvature.vertexNodalValuesAndDirections(vertices[index[0]],&dMax, &dMin, &cMax, &cMin, isAbs);
   curvature.vertexNodalValues(vertices[index[0]], curv, 1);
   if (cMin == 0) cMin =1.e-12;
   if (cMax == 0) cMax =1.e-12;
   double rhoMin = 1./cMin;
   double rhoMax = 1./cMax;
   //double signMin = (rhoMin > 0.0) ? -1.0: 1.0;
   //double signMax = (rhoMax > 0.0) ? -1.0: 1.0;

   //user-defined parameters
   //define h_n, h_t1, and h_t2
   double thickness = radMax/3.;
   double h_far = radMax/5.;
   double beta = (ds <= thickness) ? 1.2 : 2.1; //CTX::instance()->mesh.smoothRatio;
   double ddist = (ds <= thickness) ? ds: thickness;

   double h_n_0 = thickness/20.;
   double h_n   = std::min( (h_n_0+ds*log(beta)), h_far);

   double betaMin = 10.0;
   double betaMax = 3.1;
   double oneOverD2_min = 1./(2.*rhoMin*rhoMin*(betaMin*betaMin-1)) *
     (sqrt(1+ (4.*rhoMin*rhoMin*(betaMin*betaMin-1))/(h_n*h_n))-1.);
   double oneOverD2_max = 1./(2.*rhoMax*rhoMax*(betaMax*betaMax-1)) *
    (sqrt(1+ (4.*rhoMax*rhoMax*(betaMax*betaMax-1))/(h_n*h_n))-1.);
   double h_t1_0 = sqrt(1./oneOverD2_min);
   double h_t2_0 = sqrt(1./oneOverD2_max);
   //double h_t1 =  h_t1_0*(rhoMin+signMin*ddist)/rhoMin ;
   //double h_t2 =  h_t2_0*(rhoMax+signMax*ddist)/rhoMax ;
   double h_t1  = std::min( (h_t1_0+(ddist*log(beta))), radMax);
   double h_t2  = std::min( (h_t2_0+(ddist*log(beta))), h_far);

   double dCenter = radMax-ds;
   double h_a_0 = 0.5*radMax;
   double h_a = h_a_0 - (h_a_0-h_t1_0)/(radMax)*dCenter;

   //length between min and max
   double lcMin = ((2 * M_PI *radMax) /( 50*nbPoints )); //CTX::instance()->mesh.lcMin;
   double lcMax =  lcMin*2000.; //CTX::instance()->mesh.lcMax;
   h_n = std::max(h_n, lcMin);    h_n = std::min(h_n, lcMax);
   h_t1 = std::max(h_t1, lcMin);  h_t1 = std::min(h_t1, lcMax);
   h_t2 = std::max(h_t2, lcMin);  h_t2 = std::min(h_t2, lcMax);

   //curvature metric
   SMetric3 curvMetric, curvMetric1, curvMetric2;
   SMetric3 centMetric1, centMetric2, centMetric;
   if (onInOutlets){
     metr = buildMetricTangentToCurve(dir_n,h_n,h_t2);
   }
   else {
     //on surface and in volume boundary layer
     if ( ds < thickness ){
       metr = metricBasedOnSurfaceCurvature(dMin, dMax, cMin, cMax, h_n, h_t1, h_t2);
     }
     //in volume
     else {
       //curvMetric = metricBasedOnSurfaceCurvature(dMin, dMax, cMin, cMax, h_n, h_t1, h_t2);
       metr = SMetric3( 1./(h_a*h_a), 1./(h_n*h_n), 1./(h_n*h_n), dir_a, dir_n, dir_cross);

       //metr = intersection_conserveM1_bis(metr, curvMetric);
       //metr = intersection_conserveM1(metr,curvMetric);
       //metr = intersection_conserve_mostaniso(metr, curvMetric);
       //metr = intersection(metr,curvMetric);
     }
   }

   return;

}
コード例 #30
0
ファイル: LessParser.cpp プロジェクト: trav-c/clessc
bool LessParser::parseAtRuleOrVariable (LessStylesheet &stylesheet) {
  string keyword, import;
  TokenList value, rule;
  AtRule* atrule = NULL;
  
  if (tokenizer->getTokenType() != Token::ATKEYWORD) 
    return false;

  keyword = tokenizer->getToken();
  tokenizer->readNextToken();
  skipWhitespace();

#ifdef WITH_LIBGLOG
  VLOG(2) << "Parse: keyword: " << keyword;
#endif
    
  if (parseVariable(value)) {
#ifdef WITH_LIBGLOG
    VLOG(2) << "Parse: variable";
#endif
    stylesheet.putVariable(keyword, value);
    
  } else {
    if (keyword == "@media") {
      parseLessMediaQuery(stylesheet);
      return true;
    }
    
    while(parseAny(rule)) {};
  
    if (!parseBlock(rule)) {
      if (tokenizer->getTokenType() != Token::DELIMITER) {
        throw new ParseException(tokenizer->getToken(),
                                 "delimiter (';') at end of @-rule",
                                 tokenizer->getLineNumber(),
                                 tokenizer->getColumn(),
                                 tokenizer->getSource());
      }
      tokenizer->readNextToken();
      skipWhitespace();
    }
    // parse import
    if (keyword == "@import") {
      if (rule.size() != 1 ||
          rule.front().type != Token::STRING)
        throw new ParseException(rule.toString(), "A string with the \
file path",
                                 tokenizer->getLineNumber(),
                                 tokenizer->getColumn(),
                                 tokenizer->getSource());
      import = rule.front();
#ifdef WITH_LIBGLOG
      VLOG(2) << "Import filename: " << import;
#endif
      if (import.size() < 5 ||
          import.substr(import.size() - 5, 4) != ".css") {
        if (import.size() < 6 || import.substr(import.size() - 6, 5) != ".less")
          import.insert(import.size() - 1, ".less");
        
        importFile(import.substr(1, import.size() - 2), stylesheet);
        return true;
      }
    }
    
    atrule = stylesheet.createAtRule(keyword);
    atrule->setRule(rule);
  }
  return true;
}