void convert_xyz_to_roll_pitch(void) { //When the full-scale is set to 2g, the measurement range is -2g to +1.99975g, //and each count corresponds to 1g/4096 //(0.25 mg) at 14-bits resolution //where the COUNTS_PER_G is a constant 4096 //compute ax, ay, ax from acc_X, acc_Y, and acc_Z. acc_X, acc_Y, and acc.Z are data //output from the accelerometer on the Freedom board read_xyz(); //ax, ay, and az all have an unit of 'g' and are float data type float ax = acc_X / COUNTS_PER_G; float ay = acc_Y / COUNTS_PER_G; float az = acc_Z / COUNTS_PER_G; float tanphi = ay/az; float phi = atan(tanphi); float tantheta = -ax / sqrt(pow(ay, 2) + pow(az, 2)); float theta = atan(tantheta); //The last step is to go from accelerations (gs) to angles. The conversion //is to use trigonometry as show below. For the details on how this is //derived, you can visit the link: //http://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf //roll = //pitch = }
/* * brief - initialize the positions by reading the inputs. * */ void init(int Natoms, const char* filename){ // Memory Management m = new double[Natoms]; r = new double*[Natoms]; v = new double*[Natoms]; f = new double*[Natoms]; r_old = new double*[Natoms]; v_old = new double*[Natoms]; f_old = new double*[Natoms]; for(int i=0; i<Natoms; i++){ r[i] = new double[3]; v[i] = new double[3]; f[i] = new double[3]; r_old[i] = new double[3]; v_old[i] = new double[3]; f_old[i] = new double[3]; } // initialize the positions read_xyz(Natoms, filename); // intialize the mass, velocities, forces for(int i=0; i<Natoms; i++){ m[i] = 1.0; v[i][0] = 0.0; v[i][1] = 0.0; v[i][2] = 0.0; f[i][0] = 0.0; f[i][1] = 0.0; f[i][2] = 0.0; } }
// tests the open joystick file descriptor to see if it's really a JW, and set to read rawdata bool CSensorLinuxUSBJW::testJoystick() { // if made it here, then we have opened a joystick file descriptor m_iNumAxes = 0; m_iNumButtons = 0; memset(m_strJoystick, 0x00, 80); ioctl(m_fdJoy, JSIOCGAXES, &m_iNumAxes); ioctl(m_fdJoy, JSIOCGBUTTONS, &m_iNumButtons); ioctl(m_fdJoy, JSIOCGNAME(80), m_strJoystick); //fprintf(stdout, "joystick found = %s\n", m_strJoystick); //fflush(stdout); // compare the name of device, and number of buttons & axes with valid JoyWarrior values if (strcmp(m_strJoystick, IDSTR_JW24F8) || m_iNumButtons != NUM_BUTTON_JW24F8 || m_iNumAxes != NUM_AXES_JW24F8) { closePort(); // this far in, we need to close the port! return false; } m_piAxes = (int *) calloc( m_iNumAxes, sizeof( int ) ); memset(m_piAxes, 0x00, sizeof(int) * m_iNumAxes); m_strButton = (char *) calloc( m_iNumButtons, sizeof( char ) ); memset(m_strButton, 0x00, sizeof(char) * m_iNumButtons); fcntl( m_fdJoy, F_SETFL, O_NONBLOCK ); // use non-blocking mode // try a read float x,y,z; // "prime" the joystick reader if (! read_xyz(x,y,z)) { closePort(); // this far in, we need to close the port! return false; } // if made it here, then it's a joywarrior, set to raw data mode struct js_corr corr[NUM_AXES_JW24F8]; // Zero correction coefficient structure and set all axes to Raw mode for (int i=0; i<NUM_AXES_JW24F8; i++) { corr[i].type = JS_CORR_NONE; corr[i].prec = 0; for (int j=0; j<8; j++) { corr[i].coef[j] = 0; } } if (ioctl(m_fdJoy, JSIOCSCORR, &corr)) { fprintf(stderr, "CSensorLinuxUSBJW:: error setting correction for raw data reads\n"); } setType(SENSOR_USB_JW24F8); setPort(getTypeEnum()); return true; // if here we can return true, i.e Joywarrior found on Linux joystick port, and hopefully set to read raw data }
/* * brief - initialize the positions by reading the inputs. * */ void init(int Natoms, const char* filename){ // Memory Management m = new double[Natoms]; r = new double*[Natoms]; v = new double*[Natoms]; f = new double*[Natoms]; r_old = new double*[Natoms]; v_old = new double*[Natoms]; f_old = new double*[Natoms]; for(int i=0; i<Natoms; i++){ r[i] = new double[3]; v[i] = new double[3]; f[i] = new double[3]; r_old[i] = new double[3]; v_old[i] = new double[3]; f_old[i] = new double[3]; } // initialize the positions read_xyz(Natoms, filename); // intialize the mass, velocities, forces srand (time(NULL)); for(int i=0; i<Natoms; i++){ m[i] = 1.0; v[i][0] = 2*(double(rand())/double(RAND_MAX)) - 1.0; v[i][1] = 2*(double(rand())/double(RAND_MAX)) - 1.0; v[i][2] = 2*(double(rand())/double(RAND_MAX)) - 1.0; f[i][0] = 0.0; f[i][1] = 0.0; f[i][2] = 0.0; } // 1. Normalize the velocities so that the total momentum is zero // 2. Scale velocities such that desired temperature is obtained. // Using Velocity Re-scaling algorithm double Vx=0.0, Vy=0.0, Vz=0.0; for(int i=0; i < Natoms; i++){ Vx += v[i][0]; Vy += v[i][1]; Vz += v[i][2]; } for(int i=0; i<Natoms; i++){ v[i][0] = v[i][0] - (1.0/double(Natoms))*Vx; v[i][1] = v[i][1] - (1.0/double(Natoms))*Vy; v[i][2] = v[i][2] - (1.0/double(Natoms))*Vz; } calc_kenergy(); calc_inst_temp_pr(); double alpha = std::sqrt(Tset/T); for(int i=0; i<Natoms; i++){ v[i][0] = alpha*v[i][0]; v[i][1] = alpha*v[i][1]; v[i][2] = alpha*v[i][2]; } }
/* * brief - initialize the positions by reading the inputs. * */ void init(int Natoms, const char* filename){ r = new double*[Natoms]; f = new double*[Natoms]; for(int i=0; i<Natoms; i++){ r[i] = new double[3]; f[i] = new double[3]; } // initialize the positions read_xyz(Natoms, filename); }
void gyro_poll_fun(){ if(gyro_flags & GYRO_FLAGS_DTRDY){ read_xyz(); gyro_flags &= ~(GYRO_FLAGS_DTRDY); } if(gyro_flags & GYRO_FLAGS_OVER_THS){ put_log_mesg("GYRO: Over threshold."); gyro_flags &= ~(GYRO_FLAGS_OVER_THS); } }
void gyro_init(){ //configure gyro-spi mode discf429_spi_gyro_mode_set(); //**CS BIT INIT** //clock on GYRO_CS_GPIO_CLOCK_EN_REG |= GYRO_CS_RCC_EN_MASK; //set direction of CS pin as an output GYRO_CS_GPIO -> MODER |= GYRO_CS_MODER_MASK; //drive CS_PIN to high GYRO_CS_GPIO -> BSRR |= GYRO_CS_HIGH; //**GYRO INT1 and INT2 line config** //clock on GYRO_INT1_GPIO_CLOCK_EN_REG |= GYRO_INT1_RCC_EN_MASK; GYRO_INT2_GPIO_CLOCK_EN_REG |= GYRO_INT2_RCC_EN_MASK; //set direction of INT pins as intput GYRO_INT1_GPIO -> MODER |= 0x00 << GYRO_INT1_PIN; GYRO_INT2_GPIO -> MODER |= 0x00 << GYRO_INT2_PIN; //pull down int pins GYRO_INT1_GPIO -> PUPDR |= 0x02 << GYRO_INT1_PIN; GYRO_INT2_GPIO -> PUPDR |= 0x02 << GYRO_INT2_PIN; //drive CS_PIN to high GYRO_CS_GPIO -> BSRR |= GYRO_CS_HIGH; //SYSCFG clock on RCC -> APB2ENR |= RCC_APB2ENR_SYSCFGEN; //SYSCFG EXTI1 and EXTI2 line enabling as INT1 and INT2 SYSCFG -> EXTICR[(GYRO_INT1_EXTI_NUM*4)/32] |= GYRO_INT1_SYSCFG_EXTICR_MSK; SYSCFG -> EXTICR[(GYRO_INT2_EXTI_NUM*4)/32] |= GYRO_INT2_SYSCFG_EXTICR_MSK; // EXT1 and EXT2 conf EXTI -> IMR |= 1 << GYRO_INT1_EXTI_NUM | 1 << GYRO_INT2_EXTI_NUM; EXTI -> RTSR |= 1 << GYRO_INT1_EXTI_NUM | 1 << GYRO_INT2_EXTI_NUM; gyro_serial_command_init(); /*** MODE INIT ***/ gyro_bypass_mode_init(); /***/ for(uint32_t i =0; i < 3; i++){ init_c_buff(xyz_p[i]); } //interrupt conf NVIC->ISER[GYRO_INT1_IRQn/32] |= 0x01 << (GYRO_INT1_IRQn%32); NVIC->ISER[GYRO_INT2_IRQn/32] |= 0x01 << (GYRO_INT2_IRQn%32); //init read, necessery to make INT2/DTRDY go low read_xyz(); }
IconCanvas * IconCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "iconcanvas")) { int id = read_id(st); BrowserNode * bn = BrowserDiagram::read_diagram_ref(st); IconCanvas * result = new IconCanvas(bn, canvas, 0, 0, id); read_keyword(st, "xyz"); read_xyz(st, result); result->set_center100(); result->show(); return result; } else return 0; }
ArtifactCanvas * ArtifactCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "artifactcanvas_ref") || ((read_file_format() < 20) && !strcmp(k, "componentcanvas_ref"))) return ((ArtifactCanvas *) dict_get(read_id(st), "artifactcanvas", canvas)); else if (!strcmp(k, "artifactcanvas") || ((read_file_format() < 20) && !strcmp(k, "componentcanvas"))) { int id = read_id(st); BrowserArtifact * br = BrowserArtifact::read_ref(st, read_keyword(st)); ArtifactCanvas * result = new ArtifactCanvas(canvas, id); result->browser_node = br; connect(br->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(br->get_data(), SIGNAL(deleted()), result, SLOT(deleted())); k = read_keyword(st); read_color(st, "color", result->itscolor, k); // updates k if (strcmp(k, "xyz")) wrong_keyword(k, "xyz"); read_xyz(st, result); if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); } result->compute_size(); result->set_center100(); result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
ImageCanvas * ImageCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "image_ref")) return (ImageCanvas *) dict_get(read_id(st), "image", canvas); else if (!strcmp(k, "image")) { int id = read_id(st); QString pa = toUnicode(read_string(st)); ImageCanvas * result = new ImageCanvas(canvas, 0, 0, pa, id); read_keyword(st, "xyz"); read_xyz(st, result); read_keyword(st, "end"); result->set_center100(); result->show(); return result; } else return 0; }
int main() { std::vector<double> crd( read_xyz("ade.xyz") ); int const nat = crd.size()/3; std::vector<double> grd(3*nat,0.); pucker p( "ade.2dbspl" ); p.push_back( dihed(0,1,2,3), dihed(2,3,4,5) ); double E = p.eval( crd.data(), grd.data() ); std::cout.precision(4); std::cout.setf( std::ios::scientific, std::ios::floatfield ); std::cout << "E = " << std::setw(12) << E << "\n"; for ( int i=0; i<nat; ++i ) { for ( int k=0; k<3; ++k ) std::cout << std::setw(12) << grd[k+i*3]; std::cout << "\n"; }; return 0; }
void SdObjCanvas::read(char * & st, const char * k) { if (!strcmp(k, "mortal")) { mortal = TRUE; k = read_keyword(st); } if (!strcmp(k, "xyz")) { // new version read_xyz(st, this); k = read_keyword(st); if (!strcmp(k, "life_line_masked")) { life_line->set_masked(TRUE); k = read_keyword(st); } if (strcmp(k, "life_line_z")) wrong_keyword(k, "life_line_z"); life_line->setZ(read_double(st)); } else if (!strcmp(k, "xy")) read_xy(st, this); else wrong_keyword(k, "xy/xyz"); set_center100(); }
ParameterSetCanvas * ParameterSetCanvas::read(char * & st, UmlCanvas * canvas, char * k, ActivityActionCanvas * a) { if (!strcmp(k, "parametersetcanvas_ref")) return ((ParameterSetCanvas *) dict_get(read_id(st), "parametersetcanvas", canvas)); else if (!strcmp(k, "parametersetcanvas")) { int id = read_id(st); BrowserParameterSet * br = BrowserParameterSet::read_ref(st); ParameterSetCanvas * result = new ParameterSetCanvas(br, canvas, id, a); k = read_keyword(st); read_color(st, "color", result->itscolor, k); // updates k if (!strcmp(k, "xyz")) read_xyz(st, result); else wrong_keyword(k, "xyz"); // note : width_scale100 & height_scale100 useless, position depend on pins result->update(); result->show(); k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); result->check_stereotypeproperties(); return result; } else return 0; }
ArrowJunctionCanvas * ArrowJunctionCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "arrowjunctioncanvas")) { int id = read_id(st); BrowserClass * br = BrowserClass::read_ref(st); ArrowJunctionCanvas * result = new ArrowJunctionCanvas(canvas, 0, 0, br, id); read_keyword(st, "xyz"); read_xyz(st, result); result->set_center100(); if (read_file_format() >= 27) { read_keyword(st, "label_xy"); read_xy(st, result->label); result->label->set_center100(); } result->show(); return result; } else return 0; }
bool CSensorUSBPhidgets::detect() { int ret; float x,y,z; //test read_xyz setType(); setPort(); if (qcn_main::g_iStop) return false; // check for stop signal and function pointers if (qcn_main::g_iStop || ! setupFunctionPointers()) return false; // log Linux /* #if !defined(__APPLE_CC__) && !defined(_WIN32) if (!m_bLogging) { m_PtrCPhidget_enableLogging(PHIDGET_LOG_VERBOSE, "phidget.txt"); m_bLogging = true; } #endif */ //Declare a spatial handle m_handlePhidgetSpatial = NULL; //create the spatial object m_PtrCPhidgetSpatial_create(&m_handlePhidgetSpatial); if (!m_handlePhidgetSpatial) return false; // can't create spatial handle //Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error. //CPhidget_set_OnAttach_Handler((CPhidgetHandle) m_handlePhidgetSpatial, AttachHandler, NULL); //CPhidget_set_OnDetach_Handler((CPhidgetHandle) m_handlePhidgetSpatial, DetachHandler, NULL); //CPhidget_set_OnError_Handler((CPhidgetHandle) m_handlePhidgetSpatial, ErrorHandler, NULL); //Registers a callback that will run according to the set data rate that will return the spatial data changes //Requires the handle for the Spatial, the callback handler function that will be called, //and an arbitrary pointer that will be supplied to the callback function (may be NULL) //CPhidgetSpatial_set_OnSpatialData_Handler(m_handlePhidgetSpatial, SpatialDataHandler, NULL); //open the spatial object for device connections if ((ret = m_PtrCPhidget_open((CPhidgetHandle) m_handlePhidgetSpatial, -1))) { const char *err; m_PtrCPhidget_getErrorDescription(ret, &err); fprintf(stderr, "Phidgets error open handle %d = %s\n", ret, err); closePort(); return false; } // try a second to open double dTime = dtime(); if((ret = m_PtrCPhidget_waitForAttachment((CPhidgetHandle)m_handlePhidgetSpatial, 2000))) { const char *err; m_PtrCPhidget_getErrorDescription(ret, &err); //#if !defined(_WIN32) && !defined(__APPLE_CC__) #ifdef _DEBUG fprintf(stderr, "Phidgets error waitForAttachment %d = %s\n", ret, err); #endif //#endif closePort(); return false; } //Display the properties of the attached spatial device //display_properties((CPhidgetHandle)spatial); //Set the data rate for the spatial events // CPhidgetSpatial_setDataRate(spatial, 16); //Display the properties of the attached phidget to the screen. //We will be displaying the name, serial number, version of the attached device, the number of accelerometer, gyro, and compass Axes, and the current data rate // of the attached Spatial. m_PtrCPhidget_getSerialNumber((CPhidgetHandle) m_handlePhidgetSpatial, &m_iSerialNum); m_PtrCPhidget_getDeviceVersion((CPhidgetHandle) m_handlePhidgetSpatial, &m_iVersion); m_PtrCPhidgetSpatial_getAccelerationAxisCount(m_handlePhidgetSpatial, &m_iNumAccelAxes); m_PtrCPhidgetSpatial_getGyroAxisCount(m_handlePhidgetSpatial, &m_iNumGyroAxes); m_PtrCPhidgetSpatial_getCompassAxisCount(m_handlePhidgetSpatial, &m_iNumCompassAxes); m_PtrCPhidgetSpatial_getDataRateMax(m_handlePhidgetSpatial, &m_iDataRateMax); m_PtrCPhidgetSpatial_getDataRateMin(m_handlePhidgetSpatial, &m_iDataRateMin); m_PtrCPhidget_getDeviceName((CPhidgetHandle) m_handlePhidgetSpatial, &m_cstrDeviceName); m_PtrCPhidget_getDeviceType((CPhidgetHandle) m_handlePhidgetSpatial, &m_cstrDeviceType); m_PtrCPhidget_getDeviceLabel((CPhidgetHandle) m_handlePhidgetSpatial, &m_cstrDeviceLabel); m_PtrCPhidget_getDeviceID((CPhidgetHandle) m_handlePhidgetSpatial, &m_enumPhidgetDeviceID); if (m_iNumAccelAxes < 1) { // error as we should have 1 - 3 axes fprintf(stderr, "Error - Phidgets Accel with %d axes\n", m_iNumAccelAxes); closePort(); return false; } /* per Phidgets forum re version # : - with gyro & compass 1056 is <300 1042 is 300 - <400 1044 is 400 - <500 - no gyro or compass 1041 is <300 1043 is <400 */ if (m_iNumGyroAxes == 0 && m_iNumCompassAxes == 0) { if (m_iVersion < 300) setType(SENSOR_USB_PHIDGETS_1041); else if (m_iVersion >= 300 && m_iVersion < 400) setType(SENSOR_USB_PHIDGETS_1043); else { fprintf(stderr, "Error - Unknown Phidgets Accel with %d axes - Version %d\n", m_iNumAccelAxes, m_iVersion); closePort(); return false; } } else { if (m_iVersion < 300) setType(SENSOR_USB_PHIDGETS_1056); else if (m_iVersion >= 300 && m_iVersion < 400) setType(SENSOR_USB_PHIDGETS_1042); else setType(SENSOR_USB_PHIDGETS_1044); } setPort(getTypeEnum()); char *strSensor = new char[256]; sprintf(strSensor, "%s (Serial # %d)", getTypeStr(), m_iSerialNum); setSensorStr(strSensor); delete [] strSensor; fprintf(stdout, "%s detected in %f milliseconds\n", getSensorStr(), (dtime() - dTime) * 1000.0); // OK, at this point we should be connected, so from here on out can just read_xyz until closePort() // set as a single sample per point setSingleSampleDT(false); // mn samples itself // NB: closePort resets the type & port, so have to set again // one last sanity check, test the xyz reading if (!read_xyz(x,y,z)) { closePort(); return false; } // last setup a detach callback function if device is removed m_PtrCPhidget_set_OnAttach_Handler((CPhidgetHandle) m_handlePhidgetSpatial, PhidgetsAttachHandler, NULL); m_PtrCPhidget_set_OnDetach_Handler((CPhidgetHandle) m_handlePhidgetSpatial, PhidgetsDetachHandler, NULL); #if !defined(__APPLE_CC__) && !defined(_WIN32) if (m_bLogging) { m_PtrCPhidget_disableLogging(); m_bLogging = false; } #endif return true; }
PseudoStateCanvas * PseudoStateCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "pseudostatecanvas_ref")) return ((PseudoStateCanvas *) dict_get(read_id(st), "PseudoStateCanvas", canvas)); else if (!strcmp(k, "pseudostatecanvas")) { int id = read_id(st); BrowserPseudoState * ps = BrowserPseudoState::read_ref(st); PseudoStateCanvas * result = new PseudoStateCanvas(canvas, id); result->browser_node = ps; connect(ps->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(ps->get_data(), SIGNAL(deleted()), result, SLOT(deleted())); connect(DrawingSettings::instance(), SIGNAL(changed()), result, SLOT(modified())); k = read_keyword(st); if (!strcmp(k, "horizontal")) { result->horiz = TRUE; k = read_keyword(st); } if (!strcmp(k, "xyzwh")) { read_xyzwh(st, result); result->manual_size = TRUE; } else if (strcmp(k, "xyz")) wrong_keyword(k, "xyz"); else read_xyz(st, result); if (!ps->allow_empty()) { result->label = new LabelCanvas(ps->get_name(), canvas, 0, 0); read_keyword(st, "label_xy"); read_xy(st, result->label); result->label->setZ(result->z()); result->label->set_center100(); } if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); } result->set_xpm(); if (result->manual_size) { result->width_scale100 = result->width(); result->height_scale100 = result->height(); } result->set_center100(); result->show(); result->check_stereotypeproperties(); if (canvas->paste()) result->remove_if_already_present(); return result; } else return 0; }
CodClassInstCanvas * CodClassInstCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "classinstance_ref")) return ((CodClassInstCanvas *) dict_get(read_id(st), "classinstance", canvas)); else if (!strcmp(k, "classinstance")) { // old release and graphic instance int id = read_id(st); BrowserClass * cl = BrowserClass::read_ref(st); CodClassInstCanvas * result = new CodClassInstCanvas(cl, canvas, 0, 0, id); result->ClassInstCanvas::read(st, k); if (read_file_format() < 74) result->show_context_mode = noContext; if (!strcmp(k, "xyz")) { read_double(st); read_double(st); read_double(st); k = read_keyword(st); } if (strcmp(k, "name")) wrong_keyword(k, "name"); result->iname = read_string(st); read_keyword(st, "xyz"); read_xyz(st, result); result->compute_size(); result->set_center100(); result->show(); return result; } else if (!strcmp(k, "classinstancecanvas")) { int id = read_id(st); BrowserClassInstance * icl = BrowserClassInstance::read_ref(st); read_keyword(st, "xyz"); int x = (int) read_double(st); CodClassInstCanvas * result = new CodClassInstCanvas(icl, canvas, x, (int) read_double(st), id); result->setZ(read_double(st)); result->ClassInstCanvas::read(st, k); // update k if (read_file_format() < 74) result->show_context_mode = noContext; result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); if (result->get_type() != 0) { // not a deleted instance result->compute_size(); result->set_center100(); result->show(); result->check_stereotypeproperties(); } return result; } else return 0; }
static int populate_cameras(Vector *cameras) { size_t i; size_t n; hash *camera; char *name, *type; char *aux; set *S; Vector *vpos, *vlat, *vup; float fovy, aspect, near, far; float pos[3]; float lookAt[3]; float up[3]; int err = 0; Camera *newCamera; if(!cameras) return -1; n = sizeVector(cameras); for(i = 0; i < n; i++) { S = CreateSet(); vpos = vlat = vup = NULL; err = 0; camera = (hash *) atVector(cameras, i); name = (char *) FindHashElement(camera, "name"); type = (char *) FindHashElement(camera, "type"); if (!name) return i; if (!type) return i; InsertSetElement(S, "name"); InsertSetElement(S, "type"); err += read_hash_f(camera, S, "fovy", &fovy); err += read_hash_f(camera, S, "aspect", &aspect); err += read_hash_f(camera, S, "near", &near); err += read_hash_f(camera, S, "far", &far); if (fovy < 0.0) err++; if (aspect < 0.0) err++; if (near <= 0.0) err++; if (near <= 0.0 || far < near) err++; if (strcmp("perspective", type)) { err++; fprintf(stderr, "[W] populate_cameras: unknown type camera %s. Skipping.\n", name); } vpos = FindHashElement(camera, "pos"); if (vpos) { InsertSetElement(S, "pos"); read_xyz(vpos, &pos[0], &pos[1], &pos[2]); } vlat = FindHashElement(camera, "lookAt"); if (vlat) { InsertSetElement(S, "lookAt"); read_xyz(vlat, &lookAt[0], &lookAt[1], &lookAt[2]); } vup = FindHashElement(camera, "up"); if (vup) { InsertSetElement(S, "up"); read_xyz(vup, &up[0], &up[1], &up[2]); } if (!err) { newCamera = SceneRegisterCamera(name); if(newCamera) { InitConicCamera(newCamera, fovy, aspect, near, far); if (vpos && vlat && vup) { SetCamera(newCamera, pos[0], pos[1], pos[2], lookAt[0], lookAt[1], lookAt[2], up[0], up[1], up[2]); } } else { err++; } } // clean free(name); free(type); check_and_destroy("populate_cameras", camera, S); } return -1; }
UcClassCanvas * UcClassCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "classcanvas_ref")) return ((UcClassCanvas *) dict_get(read_id(st), "classcanvas", canvas)); else if (!strcmp(k, "classcanvas")) { int id = read_id(st); BrowserNode * br = BrowserClass::read_ref(st); UcClassCanvas * result; if (read_file_format() < 52) { read_keyword(st, "xyz"); int x = (int) read_double(st); result = new UcClassCanvas(br, canvas, x, (int) read_double(st), id); result->setZ(read_double(st)); // move the actor in its initial position x = ACTOR_CANVAS_SIZE - result->width(); if (x < 0) result->Q3CanvasRectangle::moveBy(x/2, 0); k = read_keyword(st); read_double(st); read_double(st); if (!strcmp(k, "label_xyz")) // old version read_double(st); else if (strcmp(k, "label_xy")) wrong_keyword(k, "label_xy/label_xyz"); } else { result = new UcClassCanvas(canvas, id); result->browser_node = br; connect(br->get_data(), SIGNAL(changed()), result, SLOT(modified())); connect(br->get_data(), SIGNAL(deleted()), result, SLOT(deleted())); k = read_keyword(st); result->settings.read(st, k); // updates k read_color(st, "color", result->itscolor, k); // updates k if (strcmp(k, "xyz")) wrong_keyword(k, "xyz"); read_xyz(st, result); result->compute_size(); if ((read_file_format() < 72) && (result->used_view_mode == asInterface)) { result->settings.class_drawing_mode = asClass; result->compute_size(); } if (read_file_format() >= 58) { k = read_keyword(st); result->read_stereotype_property(st, k); if (strcmp(k, "end")) wrong_keyword(k, "end"); } } result->set_center100(); result->show(); result->check_stereotypeproperties(); return result; } else return 0; }
static int populate_lights(Vector *lights) { size_t i; size_t n; int s; hash *light_h; char *name, *type, *aux; Vector *v; set *S; float r, g, b, w; float rgb[3], pos4[4]; float cutoff = 30.0; float exp = 10.0; Light *l; if (!lights) return -1; n = sizeVector(lights); for(i = 0; i < n; i++) { S = CreateSet(); light_h = (hash *) atVector(lights, i); name = (char *) FindHashElement(light_h, "name"); type = (char *) FindHashElement(light_h, "type"); if (!check_light_type(type)) { fprintf(stderr, "[E] populate_lights: bad light type %s (possible values \"positional\", \"directional\", \"spotlight\")\n", type); exit(1); } if (!name) return i; if (!type) return i; InsertSetElement(S, "name"); InsertSetElement(S, "type"); l = SceneRegisterLight(name); v = (Vector *) FindHashElement(light_h, "pos"); if (v) { InsertSetElement(S, "pos"); read_xyz(v, &pos4[0], &pos4[1], &pos4[2]); pos4[3] = 1.0; if (!strcmp(type, "directional")) pos4[3] = 0.0; SetPositionLight(l, &pos4[0]); } v = (Vector *) FindHashElement(light_h, "amb"); if (v) { InsertSetElement(S, "amb"); read_xyz(v, &rgb[0], &rgb[1], &rgb[2]); SetAmbientLight(l, &rgb[0]); } v = (Vector *) FindHashElement(light_h, "dif"); if (v) { InsertSetElement(S, "dif"); read_xyz(v, &rgb[0], &rgb[1], &rgb[2]); SetDiffuseLight(l, &rgb[0]); } v = (Vector *) FindHashElement(light_h, "spec"); if (v) { InsertSetElement(S, "spec"); read_xyz(v, &rgb[0], &rgb[1], &rgb[2]); SetSpecularLight(l, &rgb[0]); } if (!strcmp(type, "spotlight")) { aux = (char *) FindHashElement(light_h, "exp"); if (aux) { InsertSetElement(S, "exp"); sscanf(aux, "%f", &exp); if (exp < 0) { fprintf(stderr, "[E] populate_lights: negative exponent\n"); exit(1); } free(aux); } aux = (char *) FindHashElement(light_h, "cutoff"); if (aux) { InsertSetElement(S, "cutoff"); sscanf(aux, "%f", &cutoff); if (exp < 0) { fprintf(stderr, "[E] populate_lights: negative cutoff\n"); exit(1); } free(aux); } rgb[0] = 0.577; rgb[1] = 0.577; rgb[2] = 0.577; v = (Vector *) FindHashElement(light_h, "spdir"); if (v) { InsertSetElement(S, "spdir"); read_xyz(v, &rgb[0], &rgb[1], &rgb[2]); } SetSpotLight(l, &rgb[0], cutoff, exp); } aux = (char *) FindHashElement(light_h, "switched"); if (aux) { InsertSetElement(S, "switched"); sscanf(aux, "%d", &s); if (!s) SwitchLight(l, 0); free(aux); } free(type); free(name); check_and_destroy("populate_lights", light_h, S); //DestroyHash(&light_h); } DestroyVector(&lights); return -1; }
static void apply_trfm(hash *h, trfm3D *T) { trfm3D *res; Vector *v; float aux[7]; set *S; S = CreateSet(); v = FindHashElement(h, "trans"); if (v) { InsertSetElement(S, "trans"); read_xyz(v, &aux[0], &aux[1], &aux[2]); AddTransTrfm3D(T, aux[0], aux[1], aux[2]); goto atr_end; } v = FindHashElement(h, "rotVec"); if (v) { InsertSetElement(S, "rotVec"); read_fv(v, 4, &aux[0]); AddRotVecTrfm3D(T, aux[0], aux[1], aux[2], aux[3]); goto atr_end; } v = FindHashElement(h, "rotAxis"); if (v) { InsertSetElement(S, "rotAxis"); read_fv(v, 7, &aux[0]); AddRotAxisTrfm3D(T, aux[0], aux[1], aux[2], aux[3], aux[4], aux[5], aux[6]); goto atr_end; } v = FindHashElement(h, "rotX"); if (v) { InsertSetElement(S, "rotX"); read_fv(v, 1, &aux[0]); AddRot_X_Trfm3D(T, aux[0]); goto atr_end; } v = FindHashElement(h, "rotY"); if (v) { InsertSetElement(S, "rotY"); read_fv(v, 1, &aux[0]); AddRot_Y_Trfm3D(T, aux[0]); goto atr_end; } v = FindHashElement(h, "rotZ"); if (v) { InsertSetElement(S, "rotZ"); read_fv(v, 1, &aux[0]); AddRot_Z_Trfm3D(T, aux[0]); goto atr_end; } atr_end: check_and_destroy("apply_trfm", h, S); return; }
OdClassInstCanvas * OdClassInstCanvas::read(char * & st, UmlCanvas * canvas, char * k) { if (!strcmp(k, "classinstance_ref")) return ((OdClassInstCanvas *) dict_get(read_id(st), "classinstance", canvas)); else if (!strcmp(k, "classinstance")) { // old release int id = read_id(st); BrowserClass * cl = BrowserClass::read_ref(st); k = read_keyword(st); UmlColor co = UmlDefaultColor; read_color(st, "color", co, k); // updates k Uml3States ho; if (!strcmp(k, "write_horizontally") || !strcmp(k, "write_horizontaly")) { ho = state(read_keyword(st)); k = read_keyword(st); } else ho = UmlDefaultState; if (strcmp(k, "xyz")) wrong_keyword(k, "xyz"); int x = (int) read_double(st); int y = (int) read_double(st); double z = read_double(st); read_keyword(st, "name"); BrowserNode * parent = canvas->browser_diagram()->container(UmlClass); BrowserClassInstance * icl = // create a new one, don't look at already exising instances // contrarilly to the collaboration and sequence diagram // because of attributes & relations new BrowserClassInstance(read_string(st), cl, parent); OdClassInstCanvas * result = new OdClassInstCanvas(icl, canvas, x, y, id); result->setZ(z); result->itscolor = co; result->write_horizontally = ho; result->show_context_mode = noContext; k = read_keyword(st); if (!strcmp(k, "values")) ((ClassInstanceData *) icl->get_data())->read_attributes(st, k); // updates k else if (strcmp(k, "end") && strcmp(k, "xyz")) wrong_keyword(k, "end or xyz"); if (*k == 'x') read_xyz(st, result); result->compute_size(); result->set_center100(); result->show(); // to save new instance and diagram def result->package_modified(); canvas->browser_diagram()->modified(); return result; } else if (!strcmp(k, "classinstancecanvas")) { int id = read_id(st); BrowserClassInstance * icl = BrowserClassInstance::read_ref(st); read_keyword(st, "xyz"); int x = (int) read_double(st); OdClassInstCanvas * result = new OdClassInstCanvas(icl, canvas, x, (int) read_double(st), id); result->setZ(read_double(st)); result->ClassInstCanvas::read(st, k); if (read_file_format() < 74) result->show_context_mode = noContext; result->read_stereotype_property(st, k); // updates k if (strcmp(k, "end")) wrong_keyword(k, "end"); if (result->get_type() != 0) { // not a deleted instance result->compute_size(); result->set_center100(); result->show(); result->check_stereotypeproperties(); } return result; } else return 0; }
CodDirsCanvas * CodDirsCanvas::read(char *& st, UmlCanvas * canvas, char *& k) { if (!strcmp(k, "dirscanvas_ref")) return ((CodDirsCanvas *) dict_get(read_id(st), "dirs canvas", canvas)); else if (!strcmp(k, "dirscanvas")) { int id = read_id(st); double z; if (read_file_format() < 5) z = OLD_COL_MSG_Z; else { read_keyword(st, "z"); z = read_double(st); } k = read_keyword(st); CodDirsCanvas * result = new CodDirsCanvas(canvas, CodLinkCanvas::read(st, canvas, k), id); result->setZValue(z); result->link->set_dirs(result); result->link->update_pos(); // to place result k = read_keyword(st); result->settings.read(st, k); // updates k if (!strcmp(k, "forward_label")) { result->label = new LabelCanvas(read_string(st), canvas, 0, 0); if (read_file_format() < 5) { read_keyword(st, "xy"); read_xy(st, result->label); } else { read_keyword(st, "xyz"); read_xyz(st, result->label); } result->label->set_center100(); k = read_keyword(st); } if (!strcmp(k, "backward_label")) { result->backward_label = new LabelCanvas(read_string(st), canvas, 0, 0); if (read_file_format() < 5) { read_keyword(st, "xy"); read_xy(st, result->backward_label); } else { read_keyword(st, "xyz"); read_xyz(st, result->backward_label); } result->backward_label->set_center100(); k = read_keyword(st); } return result; } else return 0; }
bool CSensorMacUSBONavi::detect() { // first see if the port actually exists (the device is a "file" at /dev/tty.xrusbmodemNNN, given in STR_USB_ONAVI01 and now STR_USB_ONAVI02 since they seem to have changed the device name // use glob to match names, if count is > 0, we found a match glob_t gt; memset(>, 0x00, sizeof(glob_t)); if (glob(STR_USB_ONAVI01, GLOB_NOCHECK, NULL, >) || !gt.gl_matchc) { // either glob failed or no match // device string failed, but try the new string onavi (really Exar USB driver) may be using if (glob(STR_USB_ONAVI02, GLOB_NOCHECK, NULL, >) || !gt.gl_matchc) { // either glob failed or no match globfree(>); return false; } } char* strDevice = new char[_MAX_PATH]; memset(strDevice, 0x00, sizeof(char) * _MAX_PATH); strncpy(strDevice, gt.gl_pathv[0], _MAX_PATH); globfree(>); // can get rid of gt now if (!boinc_file_or_symlink_exists(strDevice)) { delete [] strDevice; strDevice = NULL; return false; } m_fd = open(strDevice, O_RDWR); // | O_NOCTTY | O_NONBLOCK); delete [] strDevice; // don't need strDevice after this call strDevice = NULL; if (m_fd == -1) { //failure return false; } // if here we opened the port, now set comm params struct termios tty; if (tcgetattr(m_fd, &tty) == -1) { // get current terminal state closePort(); return false; } cfmakeraw(&tty); // get raw tty settings // set terminal speed 115.2K if (cfsetspeed(&tty, B115200) == -1) { closePort(); return false; } // flow contol tty.c_iflag = 0; tty.c_oflag = 0; tty.c_cflag = CS8 | CREAD | CLOCAL; if (tcsetattr(m_fd, TCSANOW, &tty) == -1 || tcsendbreak(m_fd, 10) == -1 ) { // tcflow(m_fd, TCION) == -1) { // || tcflush(m_fd, TCIOFLUSH) == -1) { closePort(); return false; } setPort(m_fd); setSingleSampleDT(true); // onavi samples itself // try to read a value and get the sensor bit-type (& hence sensor type) float x,y,z; m_usBitSensor = 0; if (read_xyz(x,y,z) && m_usBitSensor > 0) { // exists, so setPort & Type switch(m_usBitSensor) { case 12: setType(SENSOR_USB_ONAVI_A_12); break; case 16: setType(SENSOR_USB_ONAVI_B_16); break; case 24: setType(SENSOR_USB_ONAVI_C_24); break; default: // error! closePort(); return false; } } else { closePort(); return false; } return true; }
int example(const char* in_file){ msym_error_t ret = MSYM_SUCCESS; msym_element_t *elements = NULL; msym_orbital_t *orbitals = NULL, **porbitals = NULL; const char *error = NULL; char point_group[6]; double cm[3], radius = 0.0, symerr = 0.0; /* Do not free these variables */ msym_element_t *melements = NULL; msym_symmetry_operation_t *msops = NULL; msym_subgroup_t *msg = NULL; int msgl = 0, msopsl = 0, mlength = 0; /* This function reads xyz files. * It initializes an array of msym_element_t to 0, * then sets the coordinates and name of the elements */ int length = read_xyz(in_file, &elements); if(length <= 0) return -1; double (*coefficients)[length] = NULL; /* Allocate and initialize memory for orbitals */ orbitals = calloc(length, sizeof(msym_orbital_t)); porbitals = calloc(length, sizeof(msym_orbital_t*)); /* Add a 1s orbital to each atom */ for(int i = 0;i < length;i++){ /* You can also just set orbitals[i].n = 1 */ snprintf(orbitals[i].name,sizeof(orbitals[i].name),"1s"); porbitals[i] = &orbitals[i]; elements[i].ao = &porbitals[i]; elements[i].aol = 1; } /* Create a context */ msym_context ctx = msymCreateContext(); /* Use default thresholds otherwise call: * msymSetThresholds(msym_context ctx, msym_thresholds_t *thresholds); */ /* Set elements and orbitals */ if(MSYM_SUCCESS != (ret = msymSetElements(ctx, length, elements))) goto err; /* These are no longer needed, internal versions of these are kept in the context, * They are indexed in the same way that they have been allocated. * I.e. during orbital symmetrization or when getting the symmetrized LCAO, * the coefficients will correspond to the same indexing as "orbitals", * this is the main reason for the two levels of indirection */ free(elements); elements = NULL; free(orbitals); orbitals = NULL; free(porbitals); porbitals = NULL; /* Some trivial information */ if(MSYM_SUCCESS != (ret = msymGetCenterOfMass(ctx,cm))) goto err; if(MSYM_SUCCESS != (ret = msymGetRadius(ctx,&radius))) goto err; printf("Molecule has center of mass [%lf; %lf; %lf] " "and a radius of %lf\n",cm[0],cm[1],cm[2],radius); /* Find molecular symmetry */ if(MSYM_SUCCESS != (ret = msymFindSymmetry(ctx))) goto err; /* Get the point group name */ if(MSYM_SUCCESS != (ret = msymGetPointGroup(ctx, sizeof(char[6]), point_group))) goto err; if(MSYM_SUCCESS != (ret = msymGetSubgroups(ctx, &msgl, &msg))) goto err; printf("Found point group [0] %s select subgroup\n",point_group); for(int i = 0; i < msgl;i++) printf("\t [%d] %s\n",i+1,msg[i].name); int ssg = 0; printf("\nEnter point group[0-%d]:",msgl); while(scanf("%d", &ssg) <= 0 && ssg >= 0 && ssg <= msgl) printf("\nEnter point group[0-%d]:",msgl); if(ssg > 0){ ssg--; printf("Selected point group %s\n",msg[ssg].name); if(MSYM_SUCCESS != (ret = msymSelectSubgroup(ctx, &msg[ssg]))) goto err; /* Retreive the symmetry operations again. * Everything has been rebuilt, and the old msops is no longer valid * Neither are the equivalence sets */ if(MSYM_SUCCESS != (ret = msymGetSymmetryOperations(ctx, &msopsl, &msops))) goto err; } /* Set pointgroup to the D2h subgroup if it has Th symmetry * using the same alignment as the original. * If specific axes are wanted the alignment axes can be set instead * And of course you can keep Th if you want =D */ if(0 == strncmp(point_group, "Ih", 2) && ssg == 0){ double transform[3][3]; printf("Changing pointgroup from Th -> D2h\n"); if(MSYM_SUCCESS != (ret = msymGetAlignmentTransform(ctx, transform))) goto err; if(MSYM_SUCCESS != (ret = msymSetPointGroup(ctx, "D2h"))) goto err; if(MSYM_SUCCESS != (ret = msymSetAlignmentTransform(ctx, transform))) goto err; if(MSYM_SUCCESS != (ret = msymFindSymmetry(ctx))) goto err; if(MSYM_SUCCESS != (ret = msymGetPointGroup(ctx, sizeof(char[6]), point_group))) goto err; } /* Retreive the symmetry operations */ if(MSYM_SUCCESS != (ret = msymGetSymmetryOperations(ctx, &msopsl, &msops))) goto err; for(int i = 0; i < msopsl;i++){ if(msops[i].type == PROPER_ROTATION && msops[i].order == 3 && msops[i].power == 1){ printf("Found a C3^1 axis, YEY!\n"); } } coefficients = malloc(sizeof(double[length][length])); /* Get the subspaces for this point group (in order of irreducible representation) */ if(MSYM_SUCCESS != (ret = msymGetOrbitalSubspaces(ctx,length,coefficients))) goto err; /* Mess them up a bit */ for(int i = 0;i < length;i++){ for(int j = 0;j < length;j++){ coefficients[i][j] += i*0.001/length - j*0.001/length; } } /* And symmetrize them */ if(MSYM_SUCCESS != (ret = msymSymmetrizeOrbitals(ctx,length,coefficients))) goto err; free(coefficients); coefficients = NULL; /* Aligning axes prior to orbital symmetrization will * change the orientation of orbitals with l >= 1 */ if(MSYM_SUCCESS != (ret = msymAlignAxes(ctx))) goto err; /* Symmetrize the molecule. * You can do this before orbital symmetrization as well, * but the permutations are already built, so you don't need to */ if(MSYM_SUCCESS != (ret = msymSymmetrizeMolecule(ctx, &symerr))) goto err; printf("Molecule has been symmetrized to point group %s " "with an error of %lf\n",point_group, symerr); if(MSYM_SUCCESS != (ret = msymGetElements(ctx, &mlength, &melements))) goto err; if(mlength != length){ printf("Not possible!\n"); goto err;} printf("New element coordinates:\n%d\n\n",mlength); for(int i = 0;i < mlength;i++){ printf("%s %12.9lf %12.9lf %12.9lf\n", melements[i].name, melements[i].v[0], melements[i].v[1], melements[i].v[2]); } /* Make a new element with the same type as the first one we read */ msym_element_t myelement; memset(&myelement,0,sizeof(msym_element_t)); myelement.n = melements[0].n; myelement.v[0] = melements[0].v[0]; myelement.v[1] = melements[0].v[1]; myelement.v[2] = melements[0].v[2]; /* Generate some new elements of the same point group */ if(MSYM_SUCCESS != (ret = msymGenerateElements(ctx,1,&myelement))) goto err; /* This is not a memory leak, context keeps track of melements, * and it should never be freed, msymReleaseContext does this. */ if(MSYM_SUCCESS != (ret = msymGetElements(ctx, &mlength, &melements))) goto err; printf("Generated element coordinates:\n%d\n\n",mlength); for(int i = 0;i < mlength;i++){ printf("%s %lf %lf %lf\n", melements[i].name, melements[i].v[0], melements[i].v[1], melements[i].v[2]); } msymReleaseContext(ctx); printf("We're done!\n"); return ret; err: free(elements); free(orbitals); free(porbitals); free(coefficients); error = msymErrorString(ret); fprintf(stderr,"Error %s: ",error); error = msymGetErrorDetails(); fprintf(stderr,"%s\n",error); return ret; }
int main (int argc, char *argv[]) { int n, ib = 0, nb, flags = 0, has_q = 0; BINARYIO *bf; static char basename[33] = "Base"; if (argc < 3) print_usage (usgmsg, NULL); /* get options */ while ((n = getargs (argc, argv, options)) > 0) { switch (n) { case 'f': flags &= ~OPEN_FORTRAN; flags |= OPEN_ASCII; break; case 'u': flags &= ~OPEN_ASCII; flags |= OPEN_FORTRAN; break; case 's': mblock = 0; break; case 'p': whole = 0; break; case 'i': use_iblank = 1; /* fall through */ case 'n': has_iblank = 1; break; case 'd': is_double = 1; break; case 'M': flags &= ~MACH_UNKNOWN; flags |= get_machine (argarg); break; case 'b': ib = atoi (argarg); break; case 'B': strncpy (basename, argarg, 32); basename[32] = 0; break; case 'g': gamma = atof (argarg); if (gamma <= 1.0) FATAL (NULL, "invalid value for gamma"); break; case 'c': convert = 1; break; } } if (argind > argc - 2) print_usage (usgmsg, "XYZfile and/or CGNSfile not given"); /* read Plot3d file */ printf ("reading PLOT3D grid file %s\n", argv[argind]); printf (" as %s-block %s", mblock ? "multi" : "single", flags == OPEN_ASCII ? "ASCII" : (flags == OPEN_FORTRAN ? "FORTRAN unformatted" : "binary")); if (has_iblank) printf (" with iblank array"); putchar ('\n'); if (!file_exists (argv[argind])) FATAL (NULL, "XYZ file does not exist or is not a file"); if (NULL == (bf = bf_open (argv[argind], flags | OPEN_READ))) { fprintf (stderr, "can't open <%s> for reading", argv[argind]); exit (1); } read_xyz (bf); bf_close (bf); if (use_iblank) build_interfaces (); /* read solution file if given */ if (++argind < argc-1) { printf ("\nreading PLOT3D solution file %s\n", argv[argind]); if (!file_exists (argv[argind])) FATAL (NULL, "Solution file does not exist or is not a file"); if (NULL == (bf = bf_open (argv[argind], flags | OPEN_READ))) { fprintf (stderr, "can't open <%s> for reading", argv[argind]); exit (1); } read_q (bf); bf_close (bf); argind++; has_q = 1; } /* open CGNS file */ printf ("\nwriting CGNS file to %s\n", argv[argind]); nb = open_cgns (argv[argind], 0); if (ib) { if (ib > nb) FATAL (NULL, "specified base index out of range"); if (cg_base_read (cgnsfn, ib, basename, &n, &n)) FATAL (NULL, NULL); } if (cg_base_write (cgnsfn, basename, 3, 3, &cgnsbase) || cg_goto (cgnsfn, cgnsbase, "end") || cg_dataclass_write (CGNS_ENUMV(NormalizedByUnknownDimensional))) FATAL (NULL, NULL); printf (" output to base %d - %s\n", cgnsbase, basename); write_zones (); for (n = 1; n <= nZones; n++) { printf ("writing zone %d ... grid", n); fflush (stdout); write_zone_grid (n); write_zone_interface (n); if (has_q) { printf (", solution"); fflush (stdout); write_zone_solution (n, 1); write_solution_field (n, 1, 0); } puts (" done"); } if (has_q) write_reference (); cg_close (cgnsfn); return 0; }