void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {

	if (nlhs != 1 || nrhs != 7) {
		mexErrMsgTxt("Usage: [Error] = fndllSolidWorks(XY (2xN), Tilt (1xN), Rotation (1xN), Rad (1xN), strTemplate, strOutputFile, bShutdown)");
		return;
	} 

	const int *dim1 = mxGetDimensions(prhs[0]);
	int NumHoles = dim1[1];
	const int *dim2 = mxGetDimensions(prhs[1]);
	const int *dim3 = mxGetDimensions(prhs[2]);

	if (dim1[0] != 2 || dim2[0] != 1 || dim1[1] != dim2[1] || dim3[1] != NumHoles) {
		mexErrMsgTxt("Usage: [Error] = fndllSolidWorks(XY (2xN), Tilt (1xN), Rotation (1xN), Rad (1xN), strTemplate, strOutputFile, bShutdown)");
		return;
	}

	//static const double HOLE_RADIUS_M = .375*MM_TO_M;


	double *P = (double *)mxGetData(prhs[0]);
	double *Tilt = (double *)mxGetData(prhs[1]);
	double *Rot = (double *)mxGetData(prhs[2]);

	double *Rad = (double *)mxGetData(prhs[3]);

	char TemplateFile[1000], OutputFile[1000];
	
	mxGetString(prhs[4], TemplateFile, 999);
	mxGetString(prhs[5], OutputFile, 999);

	bool bShutdown = (*(char *)mxGetData(prhs[6])) > 0;

        std::string saveFilename(OutputFile);
		std::string templateFileName(TemplateFile);

        vector<double> x_mm_list;
        vector<double> y_mm_list;
		vector<double> r_mm_list;

        vector<double > tilt_degrees_list;
        vector<double> rotation_degrees_list;

		for(int i = 0; i< NumHoles;i++) {

                        double tilt_degrees = Tilt[i];
                        double rotation_degrees = Rot[i];

                        double x = P[2*i+0];
                        double y = P[2*i+1];
						double r = Rad[i] ;

                        x_mm_list.push_back(x);
                        y_mm_list.push_back(y);
						r_mm_list.push_back(r);
                        tilt_degrees_list.push_back(tilt_degrees);
                        rotation_degrees_list.push_back(rotation_degrees);
        }

        int Err = createRecordingChamber(x_mm_list,
                               y_mm_list,
							   tilt_degrees_list,
							   rotation_degrees_list,
							   r_mm_list,
							   saveFilename, templateFileName,bShutdown);

		int output_dim_array[2] = {1,1};
	plhs[0] = mxCreateNumericArray(2, output_dim_array, mxDOUBLE_CLASS, mxREAL);
	double *Out = (double*) mxGetPr(plhs[0]);
	*Out = Err;

}
Ejemplo n.º 2
0
void ProjectTool::OnMenuEvent(wxCommandEvent& evt)
{
   if (evt.GetId() == MENU_IMPORT_MESH)
   {
      ImportMeshWizard* wizard = new ImportMeshWizard(mFrame);

      // Set initial import path, the user can change it.
      wxString importPath = mSelectedModule->getModulePath();
      importPath.Append("/meshes");
      wizard->importPath->SetPath(importPath);

      if (wizard->RunWizard(wizard->m_pages[0]))
      {
         wxString assetID     = wizard->assetID->GetValue();
         wxString meshPath    = wizard->meshFilePath->GetFileName().GetFullPath();
         wxString meshFile    = wizard->meshFilePath->GetFileName().GetFullName();
         wxString importPath  = wizard->importPath->GetPath();

         // Copy file (optional)
         if (wizard->copyMeshCheck->GetValue())
         {
            wxString moduleMeshPath(importPath);
            moduleMeshPath.Append("/");
            moduleMeshPath.Append(meshFile);

            Torque::Platform.createPath(moduleMeshPath.c_str());
            Torque::Platform.pathCopy(meshPath.c_str(), moduleMeshPath.c_str(), false);
            meshPath = moduleMeshPath;
         }

         // Make path relative to module directory.
         char buf[1024];
         const char* fullPath = Torque::Platform.makeFullPathName(meshPath.c_str(), buf, sizeof(buf), NULL);
         StringTableEntry relativePath = Torque::Platform.makeRelativePathName(fullPath, importPath);

         // Create full import path.
         importPath.Append("/");
         importPath.Append(assetID);
         importPath.Append(".asset.taml");

         // Create asset definition.
         Torque::Scene.createMeshAsset(assetID.c_str(), relativePath, importPath.c_str());
         Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, importPath.c_str());
         refresh();
      }

      wizard->Destroy();
   }

   if (evt.GetId() == MENU_IMPORT_TEXTURE)
   {
      ImportTextureWizard* wizard = new ImportTextureWizard(mFrame);
      
      // Set initial import path, the user can change it.
      wxString importPath = mSelectedModule->getModulePath();
      importPath.Append("/textures");
      wizard->importPath->SetPath(importPath);

      if (wizard->RunWizard(wizard->m_pages[0]))
      {
         wxString assetID = wizard->assetID->GetValue();
         wxString texturePath = wizard->textureFilePath->GetFileName().GetFullPath();
         wxString textureFile = wizard->textureFilePath->GetFileName().GetFullName();
         wxString importPath = wizard->importPath->GetPath();

         // Copy file (optional)
         if (wizard->copyTextureCheck->GetValue())
         {
            wxString moduleTexturePath(importPath);
            moduleTexturePath.Append("/");
            moduleTexturePath.Append(textureFile);

            Torque::Platform.createPath(moduleTexturePath.c_str());
            Torque::Platform.pathCopy(texturePath.c_str(), moduleTexturePath.c_str(), false);
            texturePath = moduleTexturePath;
         }

         // Make path relative to module directory.
         char buf[1024];
         const char* fullPath = Torque::Platform.makeFullPathName(texturePath.c_str(), buf, sizeof(buf), NULL);
         StringTableEntry relativePath = Torque::Platform.makeRelativePathName(fullPath, importPath);

         // Create full import path.
         importPath.Append("/");
         importPath.Append(assetID);
         importPath.Append(".asset.taml");

         // Create asset definition.
         Torque::Scene.createTextureAsset(assetID.c_str(), relativePath, importPath.c_str());
         Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, importPath.c_str());
         refresh();
      }

      wizard->Destroy();
   }

   if (evt.GetId() == MENU_NEW_MATERIAL)
   {
      NewMaterialWizard* wizard = new NewMaterialWizard(mFrame);

      // Set initial import path, the user can change it.
      wxString defaultSavePath = mSelectedModule->getModulePath();
      defaultSavePath.Append("/materials");
      wizard->savePath->SetPath(defaultSavePath);

      if (wizard->RunWizard(wizard->m_pages[0]))
      {
         wxString assetID = wizard->assetID->GetValue();
         wxString savePath = wizard->savePath->GetPath();

         wxString assetPath("");
         assetPath.Append(savePath);
         assetPath.Append("/");
         assetPath.Append(assetID);
         assetPath.Append(".asset.taml");

         wxString templateFileName("");
         templateFileName.Append(assetID);
         templateFileName.Append(".taml");

         wxString templatePath("");
         templatePath.Append(savePath);
         templatePath.Append("/");
         templatePath.Append(templateFileName);

         // Create material template and then asset.
         Torque::Scene.createMaterialTemplate(templatePath.c_str());
         Torque::Scene.createMaterialAsset(assetID.c_str(), templateFileName.c_str(), assetPath.c_str());
         Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, assetPath.c_str());
         refresh();
      }
   }
}