Ejemplo n.º 1
0
int
InputFront::unknownFieldMsg(emf_ObjectData_X* object_data, bool is_fatal)
{
  UserInterface* gui = theControlCenter->getGui();
  strstream strm;

  if ( is_fatal ) {
    strm << "***ERROR: Unknown field name (";
  } else {
    strm << "***WARNING: Unknown field name (";
  }

  strm << object_data->field_name
       << ") when reading object: "
       << object_data->object_name;

  if ( object_data->object_id != NO_INDEX ) {
    strm << " " << object_data->object_id;
  }

  strm << ends;

  gui->showMsg(strm.str());

  if (is_fatal)
    return notOk;
  else
    return isOk;
}
Ejemplo n.º 2
0
int
Control::unknownObjectMsg(emf_ObjectData_X* object_data, bool is_fatal)
{
  const int isOK = 0;

  UserInterface* gui = getGui();
  strstream strm;
  strm << "WARNING: Unknown object name: "
       << object_data->object_name
       << ends;

  gui->showMsg(strm.str());

  if (is_fatal)
    return !isOK;
  else
    return isOK;
}
Ejemplo n.º 3
0
int
InputFront::unknownObjectMsg(emf_ObjectData_X* object_data, bool is_fatal)
{
  UserInterface* gui = theControlCenter->getGui();
  strstream strm;

  if ( is_fatal ) {
    strm << "***ERROR: Unknown object name:";
  } else {
    strm << "***WARNING: Unknown object name:";
  }

  strm << object_data->object_name
       << ends;

  gui->showMsg(strm.str());

  if (is_fatal)
    return notOk;
  else
    return isOk;
}
bool
BodyElementGroup::check()
{
  UserInterface* gui = (UserInterface*)model->getGui();
  strstream strm1, strm2;

  BodyElement* be = NULL;
  bool is_first_bndr = true;

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

    int elem_tag = elementTags[i];

    switch (elemType) {
    case OT_VERTEX:
      be = model->getBodyElementByTag(OT_VERTEX, elem_tag);
      break;
    case OT_EDGE:
      be = model->getBodyElementByTag(OT_EDGE, elem_tag);
      break;
    case OT_FACE:
      be = model->getBodyElementByTag(OT_FACE, elem_tag);
      break;
    }

    if ( be != NULL ) {

      elementIds[i] = be->Id();

      // For non-virtual groups:
      // -set group info into member boundaries
      // -set parent body info
      // -check that elements are homogenous
      if ( !isVirtual() ) {

        be->setElementGroupTag(tag);
        be->setElementGroupId(id);

        // NOTE: Body info from the first element
        // (boundaries must be homogenous in this respect!)
        //
        if ( is_first_bndr ) {
          is_first_bndr = false;
          parent1Id = be->getParentId(1);
          parent2Id = be->getParentId(2);
          parent1Layer = be->getParentLayer(1);
          parent2Layer = be->getParentLayer(2);
          parent1Tag = be->getParentTag(1);
          parent2Tag = be->getParentTag(2);
        } else if ( parent1Id != be->getParentId(1) ||
                    parent2Id != be->getParentId(2)
                  ) {
            strm1 << "***ERROR in Edge Group " << tag << ends;
            strm2 << "---Edge " << be->Tag() << " is not similar to previous edges!" << ends;
            gui->showMsg(strm1.str());
            gui->showMsg(strm2.str());
            return false;
        }
      }

    // Error!
    } else {
      strm1 << "***ERROR in Edge Group " << tag << ends;
      strm2 << "---Cannot find edge " << elem_tag << ends;
      gui->showMsg(strm1.str());
      gui->showMsg(strm2.str());
      return false;
    }
  }

  return true;
}
Ejemplo n.º 5
0
// Methods read a vertex table
int
InputFront::readVertexTable(emf_ObjectData_X* od)
{
  const ModelInfo* mi = model->getModelInfo();
  int inputVersionNbr = mi->frontInputVersionNbr;

  UserInterface* gui = theControlCenter->getGui();
  const char* fn = od->field_name;

  static ecif_Vertex_X tx;
  static GcPoint point;

  int nofVertices = 0;
  int* vertexIds = NULL;
  MatcValueTable matcTable;

  bool isEgf = isEgfInput;
  bool isEmf = isEmfInput;

  reset_trx_data(tx);

  // Point table (typical Egf format)
  // ================================
  if ( LibFront::in("Points", fn) ) {

    if ( !LibFront::ncEqual(od->data_type, "real") ) {
      gui->showMsg("Incorrect data format for vertex points (should be Real!)");
      return 1;
    }

    int tag, dim1, dim2;
    bool indexed_table;
    double coord[3];
    BodyElement* vertex;

    if ( od->nof_variables == 1 &&
         LibFront::ncEqual(od->variable_names[0], "index")
       ) {
      indexed_table = true;
      dim1 = od->nof_entries;
      dim2 = od->dimension1;
    } else {
      indexed_table = false;
      dim1 = od->dimension1;
      dim2 = od->dimension2;
    }

    vertexIds = new int[dim1];

    storeMatcData(matcTable, EMF_POINTS, od);

    // Read vertex table
    for (int i = 0; i < dim1; i++) {

      coord[0] = coord[1] = coord[2] = 0.0;

      for (short j = 0; j < dim2; j++) {
        LibFront::setNumericData(coord[j], j + i * dim2);
        coord[j] *= inputUnit;
      }

      point.setPosit(coord[0], coord[1], coord[2]);

      if ( indexed_table ) {
        LibFront::setNumericVariable(tag, i);
        vertex = new BodyElement1D(tag, &point);

      } else {
        vertex = new BodyElement1D(&point);
      }

      vertexIds[i] = vertex->Id();

      model->addBodyElement(vertex);
    }

    model->setVertexTable(dim1, dim2, vertexIds, matcTable);
  }

  // Ids and Point table (typical Emf format)
  // ========================================
  // NOTE: New format
  // ----------------
  else if ( LibFront::in("Ids And Points", fn) ) {

    if ( !LibFront::ncEqual(od->data_type, "real") ) {
      gui->showMsg("Incorrect data format for vertex points (should be Real!)");
      return 1;
    }

    int data_size = od->dimension1;

    int var_size = 1; // Id field (index)

    int nof_coord;

    if ( inputVersionNbr < 5 ) {
      nof_coord = data_size;     // Nothing but index variable (id)  before coordinates
    } else {
      nof_coord = data_size - 2; // Boundary tag and boundary condition id added before coordinates
    }

     // Read table
    for (int i = 0; i < od->nof_entries; i++) {

      int var_pos = i * var_size;
      int data_pos = i * data_size;

      // Read id (as index variable!)
      LibFront::setNumericVariable(tx.tag, var_pos);

      if ( inputVersionNbr >= 5 ) {
        LibFront::setNumericData(tx.bndr_tag, data_pos++);
        LibFront::setNumericData(tx.bndr_cond_id, data_pos++);
      }

      // Read coordinates (3D)
      for (short j = 0; j < nof_coord; j++) {
        LibFront::setNumericData(tx.point[j], data_pos++);
        tx.point[j] *= inputUnit;
      }

      model->addBodyElement(tx);
    }
  }

  // Point and Constraint ids table (typical Emf format)
  // ===================================================
  // NOTE: Old format!
  // -----------------
  else if ( LibFront::in("Points And Constraint Ids", fn) ) {
    if ( !LibFront::ncEqual(od->data_type, "real") ) {
      gui->showMsg("Incorrect data format for vertex points (should be Real!)");
      return 1;
    }

    int data_size = od->dimension1;

    int nof_coord = data_size - 2;  // two ids after coordinates
    int var_size = 1;

     // Read vertex table
    for (int i = 0; i < od->nof_entries; i++) {

      int var_pos = i * var_size;
      int data_pos = i * data_size;

      // Read id
      LibFront::setNumericVariable(tx.tag, var_pos);

      // Read coordinates (3D)
      for (short j = 0; j < nof_coord; j++) {
        LibFront::setNumericData(tx.point[j], data_pos++);
        tx.point[j] *= inputUnit;
      }

      // Read boundary condition id
      LibFront::setNumericData(tx.bndr_cond_id, data_pos++);

      // Read boundary id
      LibFront::setNumericData(tx.bndr_tag, data_pos++);

      model->addBodyElement(tx);
    }
  }

  //-Unknown field
  else {
    return unknownFieldMsg(od, IS_FATAL);
  }

  delete[] vertexIds;
  purgeMatcValueTable(matcTable);

  return isOk;
}