コード例 #1
0
BOOL LLPermissions::setBaseBits(const LLUUID& agent, BOOL set, PermissionMask bits)
{
	BOOL ownership = FALSE;
	if(agent.isNull())
	{
		// only the system is always allowed to change base bits
		ownership = TRUE;
	}

	if (ownership)
	{
		if (set)
		{
			mMaskBase |= bits;		// turn on bits
		}
		else
		{
			mMaskBase &= ~bits;		// turn off bits
		}
		fix();
	}

	return ownership;
}
コード例 #2
0
ファイル: IfcGeomShapes.cpp プロジェクト: jf---/IfcOpenShell
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape& shape) {
    TopoDS_Shape s1, s2;
    IfcRepresentationShapeItems items1, items2;
    TopoDS_Wire boundary_wire;
    IfcSchema::IfcBooleanOperand* operand1 = l->FirstOperand();
    IfcSchema::IfcBooleanOperand* operand2 = l->SecondOperand();
    bool is_halfspace = operand2->is(IfcSchema::Type::IfcHalfSpaceSolid);

    if ( shape_type(operand1) == ST_SHAPELIST ) {
        if (!(convert_shapes(operand1, items1) && flatten_shape_list(items1, s1, true))) {
            return false;
        }
    } else if ( shape_type(operand1) == ST_SHAPE ) {
        if ( ! convert_shape(operand1, s1) ) {
            return false;
        }
        {   TopoDS_Solid temp_solid;
            s1 = ensure_fit_for_subtraction(s1, temp_solid);
        }
    } else {
        Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand1->entity);
        return false;
    }

    const double first_operand_volume = shape_volume(s1);
    if ( first_operand_volume <= ALMOST_ZERO )
        Logger::Message(Logger::LOG_WARNING,"Empty solid for:",l->FirstOperand()->entity);

    bool shape2_processed = false;
    if ( shape_type(operand2) == ST_SHAPELIST ) {
        shape2_processed = convert_shapes(operand2, items2) && flatten_shape_list(items2, s2, true);
    } else if ( shape_type(operand2) == ST_SHAPE ) {
        shape2_processed = convert_shape(operand2,s2);
        if (shape2_processed && !is_halfspace) {
            TopoDS_Solid temp_solid;
            s2 = ensure_fit_for_subtraction(s2, temp_solid);
        }
    } else {
        Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand2->entity);
    }

    if (!shape2_processed) {
        shape = s1;
        Logger::Message(Logger::LOG_ERROR,"Failed to convert SecondOperand of:",l->entity);
        return true;
    }

    if (!is_halfspace) {
        const double second_operand_volume = shape_volume(s2);
        if ( second_operand_volume <= ALMOST_ZERO )
            Logger::Message(Logger::LOG_WARNING,"Empty solid for:",operand2->entity);
    }

    const IfcSchema::IfcBooleanOperator::IfcBooleanOperator op = l->Operator();

    if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE) {

        bool valid_cut = false;
        BRepAlgoAPI_Cut brep_cut(s1,s2);
        if ( brep_cut.IsDone() ) {
            TopoDS_Shape result = brep_cut;

            ShapeFix_Shape fix(result);
            try {
                fix.Perform();
                result = fix.Shape();
            } catch (...) {
                Logger::Message(Logger::LOG_WARNING, "Shape healing failed on boolean result", l->entity);
            }

            bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
            if ( is_valid ) {
                shape = result;
                valid_cut = true;
            }
        }

        if ( valid_cut ) {
            const double volume_after_subtraction = shape_volume(shape);
            if ( ALMOST_THE_SAME(first_operand_volume,volume_after_subtraction) )
                Logger::Message(Logger::LOG_WARNING,"Subtraction yields unchanged volume:",l->entity);
        } else {
            Logger::Message(Logger::LOG_ERROR,"Failed to process subtraction:",l->entity);
            shape = s1;
        }

        return true;

    } else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_UNION) {

        BRepAlgoAPI_Fuse brep_fuse(s1,s2);
        if ( brep_fuse.IsDone() ) {
            TopoDS_Shape result = brep_fuse;

            ShapeFix_Shape fix(result);
            fix.Perform();
            result = fix.Shape();

            bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
            if ( is_valid ) {
                shape = result;
                return true;
            }
        }

    } else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_INTERSECTION) {

        BRepAlgoAPI_Common brep_common(s1,s2);
        if ( brep_common.IsDone() ) {
            TopoDS_Shape result = brep_common;

            ShapeFix_Shape fix(result);
            fix.Perform();
            result = fix.Shape();

            bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
            if ( is_valid ) {
                shape = result;
                return true;
            }
        }

    }
    return false;
}
コード例 #3
0
ファイル: gdsl_interval_heap.c プロジェクト: Fitor/GDSL
extern gdsl_element_t
gdsl_interval_heap_insert (gdsl_interval_heap_t heap, void* value)
{
    gdsl_element_t e;

    assert (heap != NULL);

    e = (heap->alloc_f) (value);

    if (e == NULL)
	{
	    return NULL;
	}

    if (heap->card == heap->size) 
	{
	    // the heap is full, so remove the min value and replace
	    // it with the newly inserted value
	    gdsl_element_t e1 = heap->nodes[ INDEX_MIN () ];
	    
	    // the value to be inserted is smaller than the smallest, so we just
	    // return it and do nothing.
	    if (heap->comp_f(e, e1) <= 0)
		{
		    return e;
		}
	    
        // we're inserting a node that's greater than the max
        // that means the max has to become the new min
	    if (heap->comp_f(e, heap->nodes[ INDEX_MAX() ]) > 0) 
		{
		    heap->nodes[ INDEX_MIN() ] = heap->nodes[INDEX_MAX ()];     
		    heap->nodes[ INDEX_MAX() ] = e;
		} 
	    else
		{
		    heap->nodes [ INDEX_MIN() ] = e;
		}

        taslactite_min (heap->nodes, LAST_INDEX (heap->card), LAST_INDEX (1), heap->comp_f);

        return e1;
    }

    if (3 + heap->card > heap->allocated) 
	{
	    heap->nodes = (gdsl_element_t*) realloc (heap->nodes, ((4 + (2 * heap->card)) * sizeof (gdsl_element_t)));
	    heap->allocated = (4 + (2 * heap->card));
	}

    if (heap->nodes == NULL)
	{
	    (heap->free_f) (e);
	    return NULL;
	}

    heap->card++;
    //insert into the last place available
    //if it's in the min position, it needs to be duplicated
    //in the max
    heap->nodes [ LAST_INDEX (heap->card) ] = e;
    heap->nodes [ MAX_NODE (LAST_INDEX (heap->card)) ] = e;

    fix (heap->nodes, MIN_NODE (LAST_INDEX (heap->card)), heap->comp_f);

    taslacmite_min (heap->nodes, MIN_NODE (LAST_INDEX (heap->card) ), heap->comp_f);
    taslacmite_max (heap->nodes, LAST_INDEX (heap->card), heap->comp_f);

    return NULL;
}
コード例 #4
0
void Transaction::perform(AIHTTPTimeoutPolicy* policy) const
{
  policy->mMaximumCurlTransaction = mSeconds;
  fix(policy);
  nextOp(policy);
}
コード例 #5
0
void Connect::perform(AIHTTPTimeoutPolicy* policy) const
{
  policy->mMaximumConnectTime = mSeconds;
  fix(policy);
  nextOp(policy);
}
コード例 #6
0
void
Html_File::write_token(FILE* f,
                       CXFile file,
                       CXToken tok,
                       const char* str,
                       unsigned line,
                       unsigned column)
{
  static bool preprocessor = false;
  static bool include = false;

  CXSourceLocation tloc = clang_getTokenLocation(tu_file_->tu(), tok);
  CXCursor c = clang_getCursor(tu_file_->tu(), tloc);

  if (cur_line_ <= line) cur_column_ = 1;

  for (; cur_line_ <= line; ++cur_line_)
    fprintf (f, "\n<a name=\"l%05i\"></a>%05i", cur_line_, cur_line_);

  for (; cur_column_ <= column; ++cur_column_)
    fprintf (f , " ");

  switch (clang_getTokenKind(tok)) {
  case (CXToken_Punctuation):
    if (str[0] == '#')
      preprocessor = true;
    fprintf(f, "%s", str);
    break;
  case (CXToken_Keyword):
    fprintf(f, "<span class=\"keyword\">%s</span>", str);
    break;
  case (CXToken_Comment):
    fprintf(f, "<span class=\"comment\">%s</span>", str);
    break;
  case (CXToken_Literal): {
    //include = false; // disable include links for now
    if (include) {
      include = false;
      // found an include file
      std::string t;
      const char* p = str;
      while (*p) {
        if (*p != '"')
          t += *p;
        ++p;
      }

      // first, use this file's path, then all the include paths
      bool found_include = false;
      char path[PATH_MAX];
      std::string includefile = realpath(dirname(tu_file_->source_filename()), path);
      includefile += "/" + t;
      struct stat st;
      if (stat(includefile.c_str(), &st) == 0) {
        found_include = true;
      } else {
        for (std::vector<std::string>::const_iterator i = includes_.begin(),
               e = includes_.end(); i != e; ++i) {
          includefile = realpath((*i).c_str(), path);
          includefile += "/" + t;
          if (stat(includefile.c_str(), &st) == 0) {
            found_include = true;
            break;
          }
        }
      }
      if (found_include) {
        if (files_.find(includefile) != files_.end()) {
          t = make_filename(includefile, html_dir_, prefix_, ".html", false);
          fprintf(f, "<a class=\"code\" href=\"%s\" title="">%s</a>",
                  t.c_str(), str);
          break;
        }
        std::map<std::string, Definition>::iterator i = defmap_.find(includefile);
        if (i != defmap_.end()) {
          t = i->second.file.c_str();
          fprintf(f, "<a class=\"code\" href=\"%s\" title="">%s</a>",
                  t.c_str(), str);
          break;
        }
      }
    }
    // not an include or include not found
    std::string s = fix(str);
    fprintf(f, "%s",  s.c_str() );
    break;
  }
  case (CXToken_Identifier): {
    if (preprocessor) {
      preprocessor = false;
      if (strcmp(str, "include") == 0)
        include = true;
      fprintf(f, "<span class=\"code\">%s</span>", str);
      break;
    }

    if (clang_isUnexposed(c.kind)) {
      fprintf(f, "<span class=\"code\">%s</span>", str);
      fprintf(f, "<!-- origin line: %i : %s : kind = %i -->",
              __LINE__, str, c.kind);
      break;
    }

    // Calling clang_getCursorDefinition() does not work properly
    // for template classes, i.e., it will find the method
    // declaration, not the definition, if they differ.  However,
    // once you have the declaration's location, you can use it
    // get that cursor, and find the definition that way.
    CXSourceLocation decloc =
      clang_getCursorLocation(clang_getCursorDefinition(c));
    CXCursor cref =
      clang_getCursorDefinition(clang_getCursor(tu_file_->tu(),
                                                decloc));

    if (clang_isUnexposed(cref.kind)) {
      fprintf(f, "<span class=\"code\">%s</span>", str);
          fprintf(f, "<!-- origin line: %i : (ref) %s : kind = %i -->",
                  __LINE__, str, cref.kind);
      break;
    }

    std::string rfile;
    std::string html_dir;
    unsigned refl = line;
    bool found = false;

    if (!clang_Cursor_isNull(cref) && cref.kind != CXCursor_Namespace) {
      CXSourceLocation refloc = clang_getCursorLocation(cref);
      if (!clang_equalLocations(tloc, refloc)) {
        CXFile cxfile;
        unsigned col;
        unsigned off;
        clang_getExpansionLocation(refloc, &cxfile, &refl, &col, &off);
        if (cxfile == file) {
          found = true;
          fprintf(f, "<!-- origin line: %i : (ref) %s : kind = %i -->",
                  __LINE__, str, cref.kind);
        }
        else {
          CXString cxfn = clang_getFileName(cxfile);
          const char* fn = clang_getCString(cxfn);
          if (fn) {
            if (files_.find(fn) != files_.end()) {
              rfile = fn;
              found = true;
              fprintf(f, "<!-- origin line: %i : (ref) %s : kind = %i -->",
                      __LINE__, str, cref.kind);
            }
          }
          clang_disposeString(cxfn);
        }
      }
    }
    else if (!clang_isDeclaration(c.kind) && c.kind != CXCursor_Namespace) {
      CXCursor ref = clang_getCursorReferenced(c);
      if (ref.kind != CXCursor_Namespace) {
        std::string fsn = munge_fullyscopedname(fullyScopedName(ref));
        if (fsn.empty()) {
            fprintf(f, "<!-- origin line: %i : (fsn empty) %s : kind = %i -->",
                    __LINE__, str, c.kind);
        } else {
          std::map<std::string, Definition>::iterator r = defmap_.find(fsn);
          if (r != defmap_.end()) {
            found = true;
            fprintf(f, "<!-- origin line: %i : %s : kind = %i -->",
                    __LINE__, fsn.c_str(), c.kind);
            rfile = r->second.file.c_str();
            html_dir = r->second.html_path.c_str();
            refl = r->second.line;
          }
        }
      }
    }

    // since we are linking to lines, no need to link to same line
    if (found && (!rfile.empty() || refl != line)) {
      if (!rfile.empty())
        rfile = make_filename(rfile, html_dir, prefix_, ".html", !html_dir.empty());
      fprintf(f, "<a class=\"code\" href=\"%s#l%05i\" title="">%s</a>",
              rfile.c_str(), refl , str);
      break;
    }
    fprintf(f, "<span class=\"code\">%s</span>", str);
    break;
  }
  }
  cur_column_ += strlen(str);
}
コード例 #7
0
void Message::fix(wchar_t** slot) {
    fix(slot, sizeof(wchar_t));
}
コード例 #8
0
ファイル: verify_mapping.cpp プロジェクト: sbougerel/spatial
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_mapping_minimum, Tp, int2_sets )
{
  {
    Tp fix(100, randomize(-20, 20));
    // Prove that you can find the min value with N nodes, down to 1 nodes
    while (!fix.container.empty())
      {
        unsigned int count = 0;
        int min_value_0 = (*fix.container.begin())[0];
        int min_value_1 = (*fix.container.begin())[1];
        for(typename Tp::container_type::iterator
              i = fix.container.begin(); i != fix.container.end(); ++i)
          {
            int tmp = (*i)[0];
            if (tmp < min_value_0) { min_value_0 = tmp; }
            tmp = (*i)[1];
            if (tmp < min_value_1) { min_value_1 = tmp; }
            ++count;
          }
        BOOST_CHECK_EQUAL(count, fix.container.size());
        mapping_iterator<typename Tp::container_type> iter;
        dimension_type mapping_dim = 0;
        iter = mapping_begin(fix.container, mapping_dim);
        BOOST_CHECK_EQUAL((*iter)[mapping_dim], min_value_0);
        mapping_dim = 1;
        iter = mapping_begin(fix.container, mapping_dim);
        BOOST_CHECK_EQUAL((*iter)[mapping_dim], min_value_1);
        fix.container.erase(iter);
      }
  }
  { // A tree where all elements are the same!
    Tp fix(100, same());
    // Prove that you can find the min value with N nodes, down to 1 nodes
    while (!fix.container.empty())
      {
        unsigned int count = 0;
        for(typename Tp::container_type::iterator
              i = fix.container.begin(); i != fix.container.end(); ++i)
          { ++count; }
        BOOST_CHECK_EQUAL(count, fix.container.size());
        mapping_iterator<typename Tp::container_type> iter;
        iter = mapping_begin(fix.container, 0);
        BOOST_CHECK_EQUAL((*iter)[0], 100);
        iter = mapping_begin(fix.container, 1);
        BOOST_CHECK_EQUAL((*iter)[1], 100);
        fix.container.erase(iter);
      }
  }
  { // test at the limit: a tree with 1 element
    Tp fix(1, same());
    mapping_iterator<const typename Tp::container_type> iter;
    iter = mapping_cbegin(fix.container, 0);
    BOOST_CHECK_EQUAL((*iter)[0], 1); // should be (1, 1);
    BOOST_CHECK_EQUAL((*iter)[1], 1);
    iter = mapping_cbegin(fix.container, 1);
    BOOST_CHECK_EQUAL((*iter)[0], 1); // should be (1, 1);
    BOOST_CHECK_EQUAL((*iter)[1], 1);
  }
  { // test at the limit: an unbalanced tree (i.e. insertions in order)!
    Tp fix(100, decrease());
    mapping_iterator<typename Tp::container_type> iter;
    dimension_type mapping_dim = 0;
    iter = mapping_begin(fix.container, mapping_dim);
    BOOST_CHECK_EQUAL((*iter)[0], 1); // should be (1, 1);
    BOOST_CHECK_EQUAL((*iter)[1], 1);
  }
  { // test at the limit: an unbalanced tree (i.e insertions in order)!
    Tp fix(100, increase());
    mapping_iterator<typename Tp::container_type> iter;
    dimension_type mapping_dim = 1;
    iter = mapping_begin(fix.container, mapping_dim);
    BOOST_CHECK_EQUAL((*iter)[0], 0); // should be (0, 0);
    BOOST_CHECK_EQUAL((*iter)[1], 0);
  }
}
コード例 #9
0
//----------------------------------------------------------------------------------------------
/// Execute the algorithm.
void EstimateFitParameters::execConcrete() {
  auto costFunction = getCostFunctionInitialized();
  auto func = costFunction->getFittingFunction();

  // Use additional constraints on parameters tied in some way
  // to the varied parameters to exculde unwanted results.
  std::vector<std::unique_ptr<IConstraint>> constraints;
  std::string constraintStr = getProperty("Constraints");
  if (!constraintStr.empty()) {
    Expression expr;
    expr.parse(constraintStr);
    expr.toList();
    for (auto &term : expr.terms()) {
      IConstraint *c =
          ConstraintFactory::Instance().createInitialized(func.get(), term);
      constraints.push_back(std::unique_ptr<IConstraint>(c));
    }
  }

  // Ranges to use with random number generators: one for each free parameter.
  std::vector<std::pair<double, double>> ranges;
  ranges.reserve(costFunction->nParams());
  for (size_t i = 0; i < func->nParams(); ++i) {
    if (!func->isActive(i)) {
      continue;
    }
    auto constraint = func->getConstraint(i);
    if (constraint == nullptr) {
      func->fix(i);
      continue;
    }
    auto boundary = dynamic_cast<Constraints::BoundaryConstraint *>(constraint);
    if (boundary == nullptr) {
      throw std::runtime_error("Parameter " + func->parameterName(i) +
                               " must have a boundary constraint. ");
    }
    if (!boundary->hasLower()) {
      throw std::runtime_error("Constraint of " + func->parameterName(i) +
                               " must have a lower bound.");
    }
    if (!boundary->hasUpper()) {
      throw std::runtime_error("Constraint of " + func->parameterName(i) +
                               " must have an upper bound.");
    }
    // Use the lower and upper bounds of the constraint to set the range
    // of a generator with uniform distribution.
    ranges.push_back(std::make_pair(boundary->lower(), boundary->upper()));
  }
  // Number of parameters could have changed
  costFunction->reset();
  if (costFunction->nParams() == 0) {
    throw std::runtime_error("No parameters are given for which to estimate "
                             "initial values. Set boundary constraints to "
                             "parameters that need to be estimated.");
  }

  size_t nSamples = static_cast<int>(getProperty("NSamples"));
  unsigned int seed = static_cast<int>(getProperty("Seed"));

  if (getPropertyValue("Type") == "Monte Carlo") {
    int nOutput = getProperty("NOutputs");
    auto outputWorkspaceProp = getPointerToProperty("OutputWorkspace");
    if (outputWorkspaceProp->isDefault() || nOutput <= 0) {
      nOutput = 1;
    }
    auto output = runMonteCarlo(*costFunction, ranges, constraints, nSamples,
                                static_cast<size_t>(nOutput), seed);

    if (!outputWorkspaceProp->isDefault()) {
      auto table = API::WorkspaceFactory::Instance().createTable();
      auto column = table->addColumn("str", "Name");
      column->setPlotType(6);
      for (size_t i = 0; i < output.size(); ++i) {
        column = table->addColumn("double", std::to_string(i + 1));
        column->setPlotType(2);
      }

      for (size_t i = 0, ia = 0; i < m_function->nParams(); ++i) {
        if (m_function->isActive(i)) {
          TableRow row = table->appendRow();
          row << m_function->parameterName(i);
          for (auto &j : output) {
            row << j[ia];
          }
          ++ia;
        }
      }
      setProperty("OutputWorkspace", table);
    }
  } else {
    size_t nSelection = static_cast<int>(getProperty("Selection"));
    size_t nIterations = static_cast<int>(getProperty("NIterations"));
    runCrossEntropy(*costFunction, ranges, constraints, nSamples, nSelection,
                    nIterations, seed);
  }
  bool fixBad = getProperty("FixBadParameters");
  if (fixBad) {
    fixBadParameters(*costFunction, ranges);
  }
}
コード例 #10
0
ファイル: zero_counts.c プロジェクト: priyancka/caps
main()
{
  register struct oi_item *o;
  register struct zone_item *z;
  register struct bay_item  *b;
  register struct hw_item   *h;
  register struct pw_item   *p;
  
  extern leave();

  open_all();                             /*open all files                   */

  for(i = 0;i < NUM_PROMPTS;i++)          /*clear the buffers                */
  for(j = 0;j < BUF_SIZE;j++)
  buf[i][j] = 0;

  fix(zero_counts);
  sd_screen_off();
  sd_clear_screen();
  sd_text(zero_counts);
  sd_screen_on();
  
  while(1)
  {
    t = sd_input(&fld[0],sd_prompt(&fld[0],0),&rm,buf[0],0);
    if(t == EXIT) leave();
   
    if(code_to_caps(*buf[0]) == 'y')      /* zero the shorts counts          */
    {
      sp->sp_sh_printed = 0;
      sp->sp_sh_count = 0;
      sp->sp_rs_printed = 0;
      sp->sp_rs_count = 0;
      sp->sp_tl_printed = 0;
      sp->sp_tl_count = 0;
      sp->sp_sl_printed = 0;
      sp->sp_sl_count = 0;
      sp->sp_pl_printed = 0;
      sp->sp_pl_count = 0;
      sp->sp_bpl_printed = 0;
      sp->sp_bpl_count = 0;
      
      sp->sp_pl_order = 0;
      sp->sp_pl_print = 0;
      sp->sp_sl_order = 0;
      sp->sp_sl_print = 0;
      sp->sp_tl_order = 0;
      sp->sp_tl_print = 0;

      eh_post(ERR_CONFIRM,"Zero Counts");
      break;
    }
    else if(code_to_caps(*buf[0]) == 'n') break;

    else
    {
      eh_post(ERR_YN,0);
    }
  }
  if(sp->sp_config_status != 'y') leave();
    
  while(1)
  {
    while (1)
    {
      t = sd_input(&fld[1],sd_prompt(&fld[1],0),&rm,buf[1],0);
      if(t == EXIT) leave();
   
      if(code_to_caps(*buf[1]) == 'n' || code_to_caps(*buf[1]) == 'y') break;
 
      eh_post(ERR_YN,0);
    }
    while (1)
    {
      t = sd_input(&fld[2],sd_prompt(&fld[2],0),&rm,buf[2],0);
      if(t == EXIT) leave();
 
      if(code_to_caps(*buf[2]) == 'n' || code_to_caps(*buf[2]) == 'y') break;
 
      eh_post(ERR_YN,0);
    }
    if (code_to_caps(*buf[1]) == 'n' && code_to_caps(*buf[2]) == 'n') leave();

    if(IS_ONE_PICKLINE) pickline = op_pl;
    else
    {
      if(SUPER_OP) pickline_prompt();
      else pickline = op_pl;
    }
    if (pickline == 0 && code_to_caps(*buf[1]) == 'y')
    {
      for (i = 0; i < coh->co_pl_cnt; i++) /*for all picklines               */
      {
        pl[i].pl_complete = 0;
      }
      for (i = 0; i < coh->co_zone_cnt; i++)
      {
        zone[i].zt_count = 0;
      }
      eh_post(ERR_CONFIRM,"Zero counts");
    }
    else if (code_to_caps(*buf[1]) == 'y')
    {
      pl[pickline - 1].pl_complete = 0;

      for (i = 0; i < coh->co_zone_cnt; i++)
      {
        if (pickline == zone[i].zt_pl) zone[i].zt_count = 0;
      }
      eh_post(ERR_CONFIRM,"Zero counts");
    }
    if (code_to_caps(*buf[2]) == 'y')
    {
      sd_wait();
      
      for (i = 0; i < coh->co_pl_cnt; i++)
      {
        if (pickline && pl[i].pl_pl != pickline) continue;

        pl[i].pl_lines_to_go = 0;
        pl[i].pl_units_to_go = 0;
      }
      for (j = 0, p = pw; j < coh->co_prod_cnt; j++, p++)
      {
        h = &hw[p->pw_ptr - 1];
        if (h->hw_bay)
        {
          b = &bay[h->hw_bay - 1];
          if (b->bay_zone)
          {
            z = &zone[b->bay_zone - 1];
         
            if (pickline && z->zt_pl != pickline) continue;
            
            p->pw_units_to_go = 0;
            p->pw_lines_to_go = 0;
          }
        }
      }
      for (i = 0, o = oc->oi_tab; i < oc->of_size; i++, o++)
      {
        if (!o->oi_pl || !o->oi_on) continue;

        if (pickline && o->oi_pl != pickline) continue;
        if (o->oi_queue == OC_COMPLETE) continue;
        
        op_rec->pi_pl  = o->oi_pl;
        op_rec->pi_on  = o->oi_on;
        op_rec->pi_mod = 1;
        pick_startkey(op_rec);
      
        op_rec->pi_mod = coh->co_prod_cnt;
        pick_stopkey(op_rec);

        begin_work();
        while (!pick_next(op_rec, NOLOCK))
        {
          if (op_rec->pi_flags & PICKED)  continue;
          if (op_rec->pi_flags & NO_PICK) continue;
        
          pl[op_rec->pi_pl - 1].pl_units_to_go += op_rec->pi_ordered;
          pl[op_rec->pi_pl - 1].pl_lines_to_go += 1;
          
          pw[op_rec->pi_mod - 1].pw_units_to_go += op_rec->pi_ordered;
          pw[op_rec->pi_mod - 1].pw_lines_to_go += 1;
        }
        commit_work();
      }
      eh_post(ERR_CONFIRM, "Zero Remaining:");
    }
    if (SUPER_OP && pickline != 0 && (!(IS_ONE_PICKLINE)))
    {
      sd_cursor(0,9,1);
      sd_clear_line();
      sd_cursor(0,10,1);
      sd_clear_line();
      continue;
    }
    leave();
  }
}
コード例 #11
0
ファイル: agony.c プロジェクト: 340211173/hf-2011
int main(int argc,char **argv)
{
  HANDLE SCManager = 0; 
  HANDLE service = 0;
  HANDLE device = 0;
  SERVICE_STATUS status;
  int i=1,j;
  char sysfilepath[256];
  char devicepath[256];
  char ret[1024];
  WCHAR ToSend[512];
  DWORD code, bytes;
  char DriveLetter;
  unsigned short port;
  unsigned long space;
  
  if( argc<2 ) {
     usage(argv[0]);
     return 0;
  }
  
  // get sysfile path
  GetCurrentDirectory(sizeof(sysfilepath), sysfilepath);
  strcat( sysfilepath, "\\\\" );
  strcat( sysfilepath, SYSFILE );
  
  if( !FileExists( sysfilepath ) && strcmp(argv[1],"-stop")  && strcmp(argv[1],"-h") ) {
      printf("extracting .sys...\n");
      if( !ExtractSysFile() ) {
        printf("cannot extract sys file...\n");
        return 0;
      }  
  }

  // MultiByteToWideChar(CP_ACP, 0, argv[4], -1, ToSend, sizeof(ToSend));
  
  SCManager = OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);
  if(SCManager) {
     service = CreateService(SCManager, SERVICENAME, SERVICENAME, SERVICE_ALL_ACCESS,
             SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START,SERVICE_ERROR_NORMAL,
             sysfilepath, NULL,NULL,NULL,NULL,NULL);

     if(!service) // if we cannot create it, maybe he is already existing 
        service = OpenService(SCManager,SERVICENAME, SERVICE_ALL_ACCESS);
     
     if(service)    
        StartService(service, 0, NULL);
     else
        printf("cannot create/open the service\n");   
  }   
  else 
     printf("cannot open the service manager\n");  
   
  sprintf(devicepath,"\\\\.\\Global\\%s\0",DEVICE); 
  device = CreateFile(devicepath,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
  
  if( !device || device==INVALID_HANDLE_VALUE ) {   
     printf("cannot communicate with the driver.\n");
     CloseServiceHandle(service);
     CloseServiceHandle(SCManager);
     return 0; 
  }
   
  if( !strcmp(argv[1], "-stop")) {
     // stop & uninstall service
     
     // clean startup reg keys
     fix( NULL, FALSE );
     
     // delete VOLUME.INI files
     DeleteAllSpaceFiles();
     
     if( device ) 
        CloseHandle( device );

     if( service ) {   
        ControlService(service, SERVICE_CONTROL_STOP,&status);
        DeleteService(service);
        CloseServiceHandle(service);
     }
     
     if( SCManager )
        CloseServiceHandle(SCManager);
     return 0;
  }  
  
  if( !strcmp(argv[1], "-h")) {
     printf("all options \"cumulables\" in a same command line\n");
     printf("for exemple: agony -p process1.exe process2.exe will hide 2 process\n");
     printf("we can accumulate different options on a same line:\n");
     printf("%s -p process.exe process2.exe -s service1 -f process1.exe process2.exe\n",argv[0]);
     printf("we can also choose to launch our command one by one\n\n");
     printf("for the -space option, the syntax is:\n");
     printf("%s -space volume_letter:space_to_hide_in_MB\n",argv[0]);
     printf("we can cumulate for option -space, like other options:\n");
     printf("%s -space C:5000 D:1000 F:5500\n",argv[0]);
     return 0;   
  }   
    
  code = NO_MSG;  
    
  while( i < argc ) { 
     if( !strcmp(argv[i],"-p") ) {
        code = PROCESS_CODE;  
        i++; continue;
     }
     if( !strcmp(argv[i],"-f") ) { 
        code = FILE_CODE;    
        i++; continue;
     }   
     if( !strcmp( argv[i], "-k" ) ) {
        code = REGKEY_CODE;        
        i++; continue;
     }       
     if( !strcmp( argv[i], "-v" ) ) {
        code = REGVALUE_CODE;  
        i++; continue;
     } 
     if( !strcmp( argv[i], "-s" ) ) {
        code = SERVICE_CODE;  
        i++; continue;
     }  
     if( !strcmp( argv[i], "-tcp" ) ) {
        code = TCP_PORT_CODE;  
        i++; continue;
     }   
     if( !strcmp( argv[i], "-udp" ) ) {
        code = UDP_PORT_CODE;  
        i++; continue;
     }  
     if( !strcmp( argv[i], "-space" ) ) {
        code = DISK_SPACE_CODE;  
        i++; continue;
     }  
     if( !strcmp( argv[i], "-r" ) ) {
        // we get the initial cmdline
        ret[0] = '\0'; 
        for(j=1; j<argc; j++) {
           strcat(ret, " ");       
           strcat(ret, argv[j]);           
        }          
        fix(ret, TRUE); 
        i++; continue;
     } 
     
     
     if( code == DISK_SPACE_CODE ) {
        DriveLetter = argv[i][0];
        space = atoi( argv[i]+2 );
        if(!CreateSpaceFile(DriveLetter,space))
           printf("volume %c space will not be falsificated\n", DriveLetter);   
        // we launch the hook and we hide the VOLUME.INI file
        DeviceIoControl(device, CODEMSG(DISK_SPACE_CODE), LSPACEFILENAME, sizeof(LSPACEFILENAME), 
                                       &ret, sizeof(ret),&bytes,NULL); 
        DeviceIoControl(device, CODEMSG(FILE_CODE), LSPACEFILENAME, sizeof(LSPACEFILENAME), 
                                       &ret, sizeof(ret),&bytes,NULL);  
     }
     else if( code == TCP_PORT_CODE || code == UDP_PORT_CODE ) {
        port = atoi( argv[i] );
        DeviceIoControl(device, CODEMSG(code), &port, sizeof(port), 
                                       &ret, sizeof(ret),&bytes,NULL);
     }  
     else {
        // convert the arg to wide char before sending
        MultiByteToWideChar(CP_ACP, 0, argv[i], -1, ToSend, sizeof(ToSend));
        DeviceIoControl(device, CODEMSG(code), ToSend, (wcslen(ToSend)+1)*2, 
                                       &ret, sizeof(ret),&bytes,NULL);
     }                                  
     i++;
  }
  
  CloseHandle( device );
  if( service )
     CloseServiceHandle(service);
  if( SCManager )
     CloseServiceHandle(SCManager);
  return 0;
}
コード例 #12
0
ファイル: commands.c プロジェクト: RobDeBagel/survex
static void
cmd_fix(void)
{
   prefix *fix_name;
   node *stn = NULL;
   static node *stnOmitAlready = NULL;
   real x, y, z;
   int nx, ny, nz;
   filepos fp;

   fix_name = read_prefix(PFX_STATION|PFX_ALLOW_ROOT);
   fix_name->sflags |= BIT(SFLAGS_FIXED);

   get_pos(&fp);
   get_token();
   if (strcmp(ucbuffer, "REFERENCE") == 0) {
      /* suppress "unused fixed point" warnings for this station */
      fix_name->sflags |= BIT(SFLAGS_USED);
   } else {
      if (*ucbuffer) set_pos(&fp);
   }

   x = read_numeric(fTrue, &nx);
   if (x == HUGE_REAL) {
      /* If the end of the line isn't blank, read a number after all to
       * get a more helpful error message */
      if (!isEol(ch) && !isComm(ch)) x = read_numeric(fFalse, &nx);
   }
   if (x == HUGE_REAL) {
      if (stnOmitAlready) {
	 if (fix_name != stnOmitAlready->name) {
	    compile_error_skip(/*More than one FIX command with no coordinates*/56);
	 } else {
	    compile_warning(/*Same station fixed twice with no coordinates*/61);
	 }
	 return;
      }
      stn = StnFromPfx(fix_name);
      compile_warning(/*FIX command with no coordinates - fixing at (0,0,0)*/54);
      x = y = z = (real)0.0;
      stnOmitAlready = stn;
   } else {
      real sdx;
      y = read_numeric(fFalse, &ny);
      z = read_numeric(fFalse, &nz);
      sdx = read_numeric(fTrue, NULL);
      if (sdx != HUGE_REAL) {
	 real sdy, sdz;
	 real cxy = 0, cyz = 0, czx = 0;
	 sdy = read_numeric(fTrue, NULL);
	 if (sdy == HUGE_REAL) {
	    /* only one variance given */
	    sdy = sdz = sdx;
	 } else {
	    sdz = read_numeric(fTrue, NULL);
	    if (sdz == HUGE_REAL) {
	       /* two variances given - horizontal & vertical */
	       sdz = sdy;
	       sdy = sdx;
	    } else {
	       cxy = read_numeric(fTrue, NULL);
	       if (cxy != HUGE_REAL) {
		  /* covariances given */
		  cyz = read_numeric(fFalse, NULL);
		  czx = read_numeric(fFalse, NULL);
	       } else {
		  cxy = 0;
	       }
	    }
	 }
	 stn = StnFromPfx(fix_name);
	 if (!fixed(stn)) {
	    node *fixpt = osnew(node);
	    prefix *name;
	    name = osnew(prefix);
	    name->pos = osnew(pos);
	    name->ident = NULL;
	    name->shape = 0;
	    fixpt->name = name;
	    name->stn = fixpt;
	    name->up = NULL;
	    if (TSTBIT(pcs->infer, INFER_EXPORTS)) {
	       name->min_export = USHRT_MAX;
	    } else {
	       name->min_export = 0;
	    }
	    name->max_export = 0;
	    name->sflags = 0;
	    add_stn_to_list(&stnlist, fixpt);
	    POS(fixpt, 0) = x;
	    POS(fixpt, 1) = y;
	    POS(fixpt, 2) = z;
	    fix(fixpt);
	    fixpt->leg[0] = fixpt->leg[1] = fixpt->leg[2] = NULL;
	    addfakeleg(fixpt, stn, 0, 0, 0,
		       sdx * sdx, sdy * sdy, sdz * sdz
#ifndef NO_COVARIANCES
		       , cxy, cyz, czx
#endif
		       );
	 }
	 return;
      }
      stn = StnFromPfx(fix_name);
   }

   if (!fixed(stn)) {
      POS(stn, 0) = x;
      POS(stn, 1) = y;
      POS(stn, 2) = z;
      fix(stn);
      return;
   }

   if (x != POS(stn, 0) || y != POS(stn, 1) || z != POS(stn, 2)) {
      compile_error(/*Station already fixed or equated to a fixed point*/46);
      return;
   }
   compile_warning(/*Station already fixed at the same coordinates*/55);
}
コード例 #13
0
int CParticle::UpdateDrift (int t, int nThread)
{
    m_vPos += m_vDrift * t; //(I2X (t) / 1000);

#if DBG
    CFixVector vDrift = m_vDrift;
    CFixVector::Normalize (vDrift);
    if (CFixVector::Dot (vDrift, m_vDir) < 0)
        t = t;
#endif

    if ((m_nType <= SMOKE_PARTICLES) || (m_nType == FIRE_PARTICLES)) {
        m_vDrift [X] = ChangeDir (m_vDrift [X]);
        m_vDrift [Y] = ChangeDir (m_vDrift [Y]);
        m_vDrift [Z] = ChangeDir (m_vDrift [Z]);
    }

    if (m_bHaveDir) {
        CFixVector vi = m_vDrift, vj = m_vDir;
        CFixVector::Normalize (vi);
        CFixVector::Normalize (vj);
        fix drag = Drag ();
        if (CFixVector::Dot (vi, vj) < 0)
            drag = -drag;
        m_vPos += m_vDir * drag;
    }

    int nSegment = FindSegByPos (m_vPos, m_nSegment, m_nSegment < 0, 1, (m_nType == BUBBLE_PARTICLES) ? 0 : fix (m_nRad), nThread);
    if ((0 > nSegment) && ((m_nType != WATERFALL_PARTICLES) || m_bChecked)) {
        if (m_nType == BUBBLE_PARTICLES) {
            if (SEGMENTS [nSegment].m_nType != SEGMENT_IS_WATER) {
                m_nLife = -1;
                return 0;
            }
        }
        else if (m_nType == WATERFALL_PARTICLES) {
            CFixVector vDir = m_vPos - m_vStartPos;
            if ((CFixVector::Normalize (vDir) >= I2X (1)) && (CFixVector::Dot (vDir, m_vDir) < I2X (1) / 2)) {
                m_nLife = -1;
                return 0;
            }
            if (SEGMENTS [nSegment].m_nType == SEGMENT_IS_WATER) {
                m_bChecked = 1;
                m_nLife = 500;
            }
        }
        else if (m_nTTL - m_nLife > 500) {
            m_nLife = -1;
            return 0;
        }
    }
    m_nSegment = nSegment;

    if (!Bounce (nThread))
        return 0;

    return 1;
}
コード例 #14
0
ファイル: engine.c プロジェクト: tiehuis/FastStack
///
// Attempt to perform a rotation, returning whether the rotation succeeded.
///
static bool doRotate(FSEngine *f, i8 direction)
{
    i8 newDir = (f->theta + 4 + direction) & 3;
    const FSRotationSystem *rs = rotationSystems[f->rotationSystem];

    i8 tableNo = 0;
    switch (direction) {
      case FST_ROT_CLOCKWISE:
        tableNo = rs->kicksR[f->piece];
        break;
      case FST_ROT_ANTICLOCKWISE:
        tableNo = rs->kicksL[f->piece];
        break;
      case FST_ROT_HALFTURN:
        tableNo = rs->kicksH[f->piece];
        break;
      default:
        abort();
    }

    const WallkickTable *table = tableNo >= 0
                                    ? &rs->kickTables[tableNo]
                                    : &emptyWallkickTable;

    // The `.z` field stores special wallkick flags.
    for (int k = 0; k < FS_MAX_KICK_LEN; ++k) {
        // NOTE: Check which theta we should be using here
        // We need to reverse the kick rotation here
        const i8x3 kickData = (*table)[f->theta][k];

        if (kickData.z == WK_END) {
            break;
        }

        // Handle special TGM123 rotation which is based on field state.
        if (kickData.z == WK_ARIKA_LJT && wkCondArikaLJT(f, direction)) {
            break;
        }

        int kickX = kickData.x + f->x;
        int kickY = kickData.y + f->y;

        if (!isCollision(f, kickX, kickY, newDir)) {
            // To determine a floorkick, we cannot just check the kickData.y
            // value since this may be adjusted for a different rotation system
            // (i.e. sega).
            //
            // We need to compute the difference between the current kickData.y
            // and the initial kickData.y instead to get an accurate reading.
            const int adjKickY = kickData.y - (*table)[f->theta][0].y;

            if (f->floorkickLimit && adjKickY < 0) {
                if (f->floorkickCount++ >= f->floorkickLimit) {
                    f->lockTimer = TICKS(f->lockDelay);
                }
            }

            // Preserve the fractional y drop during rotation to disallow
            // implicit lock reset.
            f->actualY = fix(kickY) + unfixfrc(f->actualY);
            f->y = kickY;
            f->x = kickX;
            f->theta = newDir;
            return true;
        }
    }

    return false;
}
コード例 #15
0
ファイル: IfcGeomShapes.cpp プロジェクト: jf---/IfcOpenShell
bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shape& shape) {
    TopoDS_Wire wire, section1, section2;

    bool hasInnerRadius = l->hasInnerRadius();

    if (!convert_wire(l->Directrix(), wire)) {
        return false;
    }

    gp_Ax2 directrix;
    {
        gp_Pnt directrix_origin;
        gp_Vec directrix_tangent;
        TopExp_Explorer exp(wire, TopAbs_EDGE);
        TopoDS_Edge edge = TopoDS::Edge(exp.Current());
        double u0, u1;
        Handle(Geom_Curve) crv = BRep_Tool::Curve(edge, u0, u1);
        crv->D1(u0, directrix_origin, directrix_tangent);
        directrix = gp_Ax2(directrix_origin, directrix_tangent);
    }

    const double r1 = l->Radius() * getValue(GV_LENGTH_UNIT);
    Handle(Geom_Circle) circle = new Geom_Circle(directrix, r1);
    section1 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle));

    if (hasInnerRadius) {
        const double r2 = l->InnerRadius() * getValue(GV_LENGTH_UNIT);
        if (r2 < getValue(GV_PRECISION)) {
            // Subtraction of pipes with small radii is unstable.
            hasInnerRadius = false;
        } else {
            Handle(Geom_Circle) circle = new Geom_Circle(directrix, r2);
            section2 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle));
        }
    }

    // NB: Note that StartParam and EndParam param are ignored and the assumption is
    // made that the parametric range over which to be swept matches the IfcCurve in
    // its entirety.
    // NB2: Contrary to IfcSurfaceCurveSweptAreaSolid the transition mode has been
    // set to create round corners as this has proven to work better with the types
    // of directrices encountered, which do not necessarily conform to a surface.
    {   BRepOffsetAPI_MakePipeShell builder(wire);
        builder.Add(section1);
        builder.SetTransitionMode(BRepBuilderAPI_RoundCorner);
        builder.Build();
        builder.MakeSolid();
        shape = builder.Shape();
    }

    if (hasInnerRadius) {
        BRepOffsetAPI_MakePipeShell builder(wire);
        builder.Add(section2);
        builder.SetTransitionMode(BRepBuilderAPI_RoundCorner);
        builder.Build();
        builder.MakeSolid();
        TopoDS_Shape inner = builder.Shape();

        BRepAlgoAPI_Cut brep_cut(shape, inner);
        bool is_valid = false;
        if (brep_cut.IsDone()) {
            TopoDS_Shape result = brep_cut;

            ShapeFix_Shape fix(result);
            fix.Perform();
            result = fix.Shape();

            is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
            if (is_valid) {
                shape = result;
            }
        }

        if (!is_valid) {
            Logger::Message(Logger::LOG_WARNING, "Failed to subtract inner radius void for:", l->entity);
        }
    }

    return true;
}
コード例 #16
0
ファイル: verify_mapping.cpp プロジェクト: sbougerel/spatial
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_mapping_decrement, Tp, int2_maps )
{
  { // test the invarient of the increment
    Tp fix(100, randomize(-3, 3));
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        double tmp = iter->first[mapping_dim];
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_GE(tmp, iter->first[mapping_dim]);
            tmp = iter->first[mapping_dim];
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
  { // test at the limit: a tree where all elements are the same
    Tp fix(100, same());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_EQUAL(100, iter->first[mapping_dim]);
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
  { // test at the limit: a tree with 2 elements
    Tp fix(2, same());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        mapping_iterator<const typename Tp::container_type>
          pre = mapping_cend(fix.container, mapping_dim),
          post = mapping_cend(fix.container, mapping_dim),
          begin = mapping_cbegin(fix.container, mapping_dim);
        BOOST_CHECK(pre != begin);
        BOOST_CHECK(--pre != post--);
        BOOST_CHECK(pre == post);
        BOOST_CHECK(post-- != begin);
        BOOST_CHECK(--pre == begin);
        BOOST_CHECK(post == begin);
      }
  }
  { // test at the limit: a right-unbalanced tree (pre-increment)
    Tp fix(100, increase());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        double tmp = iter->first[mapping_dim];
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_GE(tmp, iter->first[mapping_dim]);
            tmp = iter->first[mapping_dim];
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
  { // test at the limit: a left-unbalanced tree (post-increment)
    Tp fix(100, decrease());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        double tmp = iter->first[mapping_dim];
        for (; iter != end; iter++)
          {
            BOOST_CHECK_GE(tmp, iter->first[mapping_dim]);
            tmp = iter->first[mapping_dim];
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
}
コード例 #17
0
ファイル: verify_mapping.cpp プロジェクト: sbougerel/spatial
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_mapping_upper_bound, Tp, quad_maps )
{
  { // find the smallest element that is greater than key
    Tp fix(100, randomize(-2, 2));
    quad lower (-3, -3, -3, -3);
    quad in (-1, -1, -1, -1);
    quad upper (1, 1, 1, 1);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, in));
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim)
                    || quad_less()(mapping_dim, in, iter->first));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim)
                    || !quad_less()(mapping_dim, (--iter)->first, in));
        iter = mapping_upper_bound(fix.container, mapping_dim, lower);
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
  { // same test with a tree filled with similar values
    Tp fix(100, same());
    quad lower (99, 99, 99, 99);
    quad in (100, 100, 100, 100);
    quad upper (101, 101, 101, 101);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
  { // test at the limit: tree with 1 value
    Tp fix(1, same());
    quad lower (0, 0, 0, 0);
    quad in (1, 1, 1, 1);
    quad upper (2, 2, 2, 2);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<const typename Tp::container_type>
          iter (mapping_cupper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_cbegin(fix.container, mapping_dim));
        iter = mapping_cupper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter == mapping_cend(fix.container, mapping_dim));
        iter = mapping_cupper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_cend(fix.container, mapping_dim));
      }
  }
  { // test at the limit: tree filled with decreasing values
    Tp fix(100, decrease()); // first (100, 100, 100, 100), last (1, 1, 1, 1)
    quad lower(0, 0, 0, 0);
    quad in (99, 99, 99, 99);
    quad upper(100, 100, 100, 100);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter != mapping_end(fix.container, mapping_dim)
                    && ++iter == mapping_end(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
  { // test at the limit: tree filled with increasing values
    Tp fix(100, increase()); // first (0, 0, 0, 0), last (99, 99, 99, 99)
    quad lower(-1, -1, -1, -1);
    quad in(98, 98, 98, 98);
    quad upper (99, 99, 99, 99);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter != mapping_end(fix.container, mapping_dim)
                    && ++iter == mapping_end(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
}
コード例 #18
0
ファイル: cvt.c プロジェクト: jhallen/joes-sandbox
int main(int argc, char *argv[])
{
	int blankf = 0;
	while (gets(buf))
		if (buf[0] == '.' && buf[1] == '\\' && buf[2] == '"');
		else if (dot(".ne"));
		else if (dot(".ns"));
		else if (dot(".HP"));
		else if (dot(".sp") || dot(".br")) {
			flsh();
			if (!blankf)
				putchar('\n'), blankf = 1;
		} else if (dot(".SH")) {
			flsh();
			indent = 8;
			fix(buf + 3);
			out(0, buf + 3);
		} else if (dot(".DA"));
		else if (dot(".I") || dot(".R")) {
			blankf = 0;
			hold(buf + 2);
		} else if (dot(".IR")) {
			blankf = 0;
			nhold(buf + 3);
		} else if (dot(".BI")) {
			blankf = 0;
			ihold(buf + 3);
		} else if (dot(".RB") || dot(".SM") || dot(".BR")
			   || dot(".RS") || dot(".RE")) {
			blankf = 0;
			hold(buf + 3);
		} else if (dot(".SS")) {
			flsh();
			indent = 8;
			fix(buf + 3);
			out(4, buf + 3);
		} else if (dot(".PP") || dot(".LP")) {
			flsh();
			indent = 8;
			if (!blankf)
				putchar('\n'), blankf = 1;
		} else if (dot(".B")) {
			blankf = 0;
			hold(buf + 2);
		} else if (dot(".IP") || dot(".TP")) {
			flsh();
			indent = 8;
			if (!blankf)
				putchar('\n'), blankf = 1;
			fix(buf + 3);
			if (strlen(buf + 3) > 8) {
				out(indent, buf + 3);
				indent = 16;
			} else {
				int x;
				for (x = 0; x != indent; ++x)
					putchar(' ');
				if (buf[3]) {
					for (x = 0; buf[x + 4]; ++x)
						putchar(buf[x + 4]);
					curcol = x + indent;
					indent = 16;
				}
			}
		} else if (!buf[0] && !blankf) {
			flsh();
			++blankf;
			putchar('\n');
		} else if (dot(".TH"))
			flsh();
		else if (buf[0] == '.')
			fprintf(stderr, "Unknown sequence '.%c%c'\n",
				buf[1], buf[2]);
		else if (buf[0]) {
			hold(buf);
			blankf = 0;
		}
	flsh();
	return 0;
}
コード例 #19
0
void Message::fix(char** slot) {
    fix(slot, sizeof(char));
}
コード例 #20
0
ファイル: object.cpp プロジェクト: thefightingferret/tfe-1.0
void load_objects( void )
{
  FILE*                 fp;
  obj_clss_data*  obj_clss;
  oprog_data*        oprog;
  char              letter;
  int                    i;
  int                 vnum;

  echo( "Loading Objects ...\r\n" );
  vzero( obj_index_list, MAX_OBJ_INDEX );

  fp = open_file( AREA_DIR, OBJECT_FILE, "r", TRUE );

  if( strcmp( fread_word( fp ), "#OBJECTS" ) ) 
    panic( "Load_objects: header not found" );

  for( ; ; ) {
    letter = fread_letter( fp );

    if( letter != '#' ) 
      panic( "Load_objects: # not found." );

    if( ( vnum = fread_number( fp ) ) == 0 )
      break;
   
    if( vnum < 0 || vnum >= MAX_OBJ_INDEX ) 
      panic( "Load_objects: vnum out of range." );

    if( obj_index_list[vnum] != NULL ) 
      panic( "Load_objects: vnum %d duplicated.", vnum );

    obj_clss = new obj_clss_data;
 
    obj_index_list[vnum]  = obj_clss;
    obj_clss->vnum        = vnum;
    obj_clss->fakes       = vnum;

    obj_clss->singular         = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->plural           = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->before           = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->after            = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->long_s           = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->long_p           = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->prefix_singular  = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->prefix_plural    = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->creator          = fread_string( fp, MEM_OBJ_CLSS );
    obj_clss->last_mod         = fread_string( fp, MEM_OBJ_CLSS );      

    obj_clss->item_type       = fread_number( fp );
    obj_clss->fakes           = fread_number( fp );
    obj_clss->extra_flags[0]  = fread_number( fp );
    obj_clss->extra_flags[1]  = fread_number( fp );
    obj_clss->wear_flags      = fread_number( fp );
    obj_clss->anti_flags      = fread_number( fp );
    obj_clss->restrictions    = fread_number( fp );
    obj_clss->size_flags      = fread_number( fp );
    obj_clss->materials       = fread_number( fp );

    obj_clss->affect_flags[0] = fread_number( fp );
    obj_clss->affect_flags[1] = fread_number( fp );
    obj_clss->affect_flags[2] = fread_number( fp );
    obj_clss->layer_flags     = fread_number( fp );

    obj_clss->value[0]      = fread_number( fp );
    obj_clss->value[1]      = fread_number( fp );
    obj_clss->value[2]      = fread_number( fp );
    obj_clss->value[3]      = fread_number( fp );

    obj_clss->weight        = fread_number( fp );
    obj_clss->cost          = fread_number( fp );
    obj_clss->level         = fread_number( fp );
    obj_clss->limit         = fread_number( fp );
    obj_clss->repair        = fread_number( fp );
    obj_clss->durability    = fread_number( fp );
    obj_clss->blocks        = fread_number( fp );
    obj_clss->light         = fread_number( fp );

    obj_clss->date          = fread_number( fp );

    read_affects( fp, obj_clss ); 
    read_extra( fp, obj_clss->extra_descr );

    fread_letter( fp );

    for( ; ; ) {
      int number = fread_number( fp );

      if( number == -1 )
        break;

      oprog = new oprog_data;
      append( obj_clss->oprog, oprog );

      oprog->trigger  = number;
      oprog->obj_vnum = fread_number( fp );
      oprog->command  = fread_string( fp, MEM_OPROG );
      oprog->target   = fread_string( fp, MEM_OPROG );
      oprog->code     = fread_string( fp, MEM_OPROG );

      read_extra( fp, oprog->data );
      }       

    fix( obj_clss );
    }

  fclose( fp );

  for( i = 0; i < MAX_OBJ_INDEX; i++ ) 
    if( obj_index_list[i] != NULL )
      for( oprog = obj_index_list[i]->oprog; oprog != NULL;
        oprog = oprog->next )
        if( oprog->obj_vnum > 0 )
          oprog->obj_act = get_obj_index( oprog->obj_vnum );
 
  return;
}
コード例 #21
0
ファイル: ikarus-runtime.c プロジェクト: hyln9/ikarus
ikptr 
ikrt_stats_now(ikptr t, ikpcb* pcb){
  struct rusage r;
  struct timeval s;

  gettimeofday(&s, 0);
  getrusage(RUSAGE_SELF, &r);
  ref(t, off_record_data)                = fix(r.ru_utime.tv_sec);
  ref(t, off_record_data + wordsize)     = fix(r.ru_utime.tv_usec);
  ref(t, off_record_data + 2 * wordsize) = fix(r.ru_stime.tv_sec);
  ref(t, off_record_data + 3 * wordsize) = fix(r.ru_stime.tv_usec);
  ref(t, off_record_data + 4 * wordsize) = fix(s.tv_sec);
  ref(t, off_record_data + 5 * wordsize) = fix(s.tv_usec);
  ref(t, off_record_data + 6 * wordsize) = fix(pcb->collection_id);
  ref(t, off_record_data + 7 * wordsize) = fix(pcb->collect_utime.tv_sec);
  ref(t, off_record_data + 8 * wordsize) = fix(pcb->collect_utime.tv_usec);
  ref(t, off_record_data + 9 * wordsize) = fix(pcb->collect_stime.tv_sec);
  ref(t, off_record_data + 10 * wordsize) = fix(pcb->collect_stime.tv_usec);
  ref(t, off_record_data + 11 * wordsize) = fix(pcb->collect_rtime.tv_sec);
  ref(t, off_record_data + 12 * wordsize) = fix(pcb->collect_rtime.tv_usec);
  {
    /* minor bytes */
    long int bytes_in_heap = ((long int) pcb->allocation_pointer) -
                             ((long int) pcb->heap_base);
    long int bytes = bytes_in_heap + pcb->allocation_count_minor;
    ref(t, off_record_data + 13 * wordsize) = fix(bytes);
  }
  /* major bytes */
  ref(t, off_record_data + 14 * wordsize) = fix(pcb->allocation_count_major);
  return void_object;
}
コード例 #22
0
LRESULT FulHighlightDialog::onApplyContext(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
	fix();
	return 0;
}
コード例 #23
0
void DNS::perform(AIHTTPTimeoutPolicy* policy) const
{
  policy->mDNSLookupGrace = mSeconds;
  fix(policy);
  nextOp(policy);
}
コード例 #24
0
ファイル: MtxLP.cpp プロジェクト: kierzek/MUFINS
void MtxLP::fix(stomap* sto, bool tmp){
    for (stomap::iterator it = sto->begin(); it != sto->end(); ++it)
        fix(it->first, it->second, tmp);
}
コード例 #25
0
void Reply::perform(AIHTTPTimeoutPolicy* policy) const
{
  policy->mMaximumReplyDelay = mSeconds;
  fix(policy);
  nextOp(policy);
}
コード例 #26
0
ファイル: MtxLP.cpp プロジェクト: kierzek/MUFINS
void MtxLP::block(string name, bool tmp, string constraintname){
    fix(name, 0, tmp, constraintname);
}
コード例 #27
0
void Total::perform(AIHTTPTimeoutPolicy* policy) const
{
  policy->mMaximumTotalDelay = mSeconds;
  fix(policy);
  nextOp(policy);
}
コード例 #28
0
ファイル: gps.cpp プロジェクト: BeaglePilot/mavros
	void message_rx_cb(const mavlink_message_t *msg, uint8_t sysid, uint8_t compid) {
		switch (msg->msgid) {
		case MAVLINK_MSG_ID_GPS_RAW_INT:
			{
				mavlink_gps_raw_int_t raw_gps;
				mavlink_msg_gps_raw_int_decode(msg, &raw_gps);

				sensor_msgs::NavSatFixPtr fix(new sensor_msgs::NavSatFix);
				geometry_msgs::TwistStampedPtr vel(new geometry_msgs::TwistStamped);

				gps_diag.set_gps_raw(raw_gps);
				if (raw_gps.fix_type < 2) {
					ROS_WARN_THROTTLE_NAMED(60, "gps", "GPS: no fix");
					return;
				}

				fix->status.service = sensor_msgs::NavSatStatus::SERVICE_GPS;
				if (raw_gps.fix_type == 2 || raw_gps.fix_type == 3)
					fix->status.status = sensor_msgs::NavSatStatus::STATUS_FIX;
				else
					fix->status.status = sensor_msgs::NavSatStatus::STATUS_NO_FIX;

				fix->latitude = raw_gps.lat / 1E7; // deg
				fix->longitude = raw_gps.lon / 1E7; // deg
				fix->altitude = raw_gps.alt / 1E3; // m

				if (raw_gps.eph != UINT16_MAX) {
					double hdop = raw_gps.eph / 1E2;
					double hdop2 = std::pow(hdop, 2);

					// TODO: Check
					// From nmea_navsat_driver
					fix->position_covariance[0] = hdop2;
					fix->position_covariance[4] = hdop2;
					fix->position_covariance[8] = pow(2 * hdop, 2);
					fix->position_covariance_type =
						sensor_msgs::NavSatFix::COVARIANCE_TYPE_APPROXIMATED;
				}
				else {
					fix->position_covariance_type =
						sensor_msgs::NavSatFix::COVARIANCE_TYPE_UNKNOWN;
				}

				fix->header.frame_id = frame_id;
				fix->header.stamp = ros::Time::now();

				fix_pub.publish(fix);

				if (raw_gps.vel != UINT16_MAX &&
						raw_gps.cog != UINT16_MAX) {
					double speed = raw_gps.vel / 1E2; // m/s
					double course = raw_gps.cog / 1E2; // deg

					// From nmea_navsat_driver
					vel->twist.linear.x = speed * std::sin(course);
					vel->twist.linear.y = speed * std::cos(course);

					vel->header.frame_id = frame_id;
					vel->header.stamp = fix->header.stamp;

					vel_pub.publish(vel);
				}
			}
			break;

		case MAVLINK_MSG_ID_GPS_STATUS:
			{
				// TODO: not supported by APM:Plane,
				//       no standard ROS messages
				mavlink_gps_status_t gps_stat;
				mavlink_msg_gps_status_decode(msg, &gps_stat);

				ROS_DEBUG_NAMED("gps", "GPS stat sat visible: %d", gps_stat.satellites_visible);
			}
			break;

		case MAVLINK_MSG_ID_SYSTEM_TIME:
			{
				mavlink_system_time_t mtime;
				mavlink_msg_system_time_decode(msg, &mtime);

				if (mtime.time_unix_usec == 0) {
					ROS_WARN_THROTTLE_NAMED(60, "gps", "Wrong system time. Is GPS Ok? (boot_ms: %u)",
							mtime.time_boot_ms);
					return;
				}

				sensor_msgs::TimeReferencePtr time(new sensor_msgs::TimeReference);
				ros::Time time_ref(
						mtime.time_unix_usec / 1000000,			// t_sec
						(mtime.time_unix_usec % 1000000) * 1000);	// t_nsec

				time->source = time_ref_source;
				time->time_ref = time_ref;
				time->header.frame_id = time_ref_source;
				time->header.stamp = ros::Time::now();

				time_ref_pub.publish(time);
			}
			break;
		};
	}
コード例 #29
0
BOOL LLPermissions::importStream(std::istream& input_stream)
{
	init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null);
	const S32 BUFSIZE = 16384;

	// *NOTE: Changing the buffer size will require changing the scanf
	// calls below.
	char buffer[BUFSIZE];	/* Flawfinder: ignore */
	char keyword[256];	/* Flawfinder: ignore */
	char valuestr[256];	/* Flawfinder: ignore */
	char uuid_str[256];	/* Flawfinder: ignore */
	U32 mask;

	keyword[0]  = '\0';
	valuestr[0] = '\0';

	while (input_stream.good())
	{
		input_stream.getline(buffer, BUFSIZE);
		if (input_stream.eof())
		{
			llwarns << "Bad permissions: early end of input stream"
					<< llendl;
			return FALSE;
		}
		if (input_stream.fail())
		{
			llwarns << "Bad permissions: failed to read from input stream"
					<< llendl;
			return FALSE;
		}
		sscanf( /* Flawfinder: ignore */
			buffer,
			" %255s %255s",
			keyword, valuestr);
		if (!strcmp("{", keyword))
		{
			continue;
		}
		if (!strcmp("}",keyword))
		{
			break;
		}
		else if (!strcmp("creator_mask", keyword))
		{
			// legacy support for "creator" masks
			sscanf(valuestr, "%x", &mask);
			mMaskBase = mask;
			fixFairUse();
		}
		else if (!strcmp("base_mask", keyword))
		{
			sscanf(valuestr, "%x", &mask);
			mMaskBase = mask;
			//fixFairUse();
		}
		else if (!strcmp("owner_mask", keyword))
		{
			sscanf(valuestr, "%x", &mask);
			mMaskOwner = mask;
		}
		else if (!strcmp("group_mask", keyword))
		{
			sscanf(valuestr, "%x", &mask);
			mMaskGroup = mask;
		}
		else if (!strcmp("everyone_mask", keyword))
		{
			sscanf(valuestr, "%x", &mask);
			mMaskEveryone = mask;
		}
		else if (!strcmp("next_owner_mask", keyword))
		{
			sscanf(valuestr, "%x", &mask);
			mMaskNextOwner = mask;
		}
		else if (!strcmp("creator_id", keyword))
		{
			sscanf(valuestr, "%255s", uuid_str);	/* Flawfinder: ignore */
			mCreator.set(uuid_str);
		}
		else if (!strcmp("owner_id", keyword))
		{
			sscanf(valuestr, "%255s", uuid_str);	/* Flawfinder: ignore */
			mOwner.set(uuid_str);
		}
		else if (!strcmp("last_owner_id", keyword))
		{
			sscanf(valuestr, "%255s", uuid_str);	/* Flawfinder: ignore */
			mLastOwner.set(uuid_str);
		}
		else if (!strcmp("group_id", keyword))
		{
			sscanf(valuestr, "%255s", uuid_str);	/* Flawfinder: ignore */
			mGroup.set(uuid_str);
		}
		else if (!strcmp("group_owned", keyword))
		{
			sscanf(valuestr, "%d", &mask);
			if(mask) mIsGroupOwned = true;
			else mIsGroupOwned = false;
		}
		else
		{
			llwarns << "unknown keyword " << keyword 
					<< " in permissions import" << llendl;
		}
	}
	fix();
	return TRUE;
}
コード例 #30
0
ファイル: verify_mapping.cpp プロジェクト: sbougerel/spatial
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_mapping_maximum, Tp, int2_sets )
{
  {
    Tp fix(100, randomize(-20, 20));
    // Prove that you can find the max value with N nodes, down to 1 nodes
    while (!fix.container.empty())
      {
        unsigned int count = 0;
        int max_value_0 = (*fix.container.begin())[0];
        int max_value_1 = (*fix.container.begin())[1];
        for(typename Tp::container_type::iterator
              i = fix.container.begin(); i != fix.container.end(); ++i)
          {
            int tmp = (*i)[0];
            if (tmp > max_value_0) { max_value_0 = tmp; }
            tmp = (*i)[1];
            if (tmp > max_value_1) { max_value_1 = tmp; }
            ++count;
          }
        BOOST_CHECK_EQUAL(count, fix.container.size());
        mapping_iterator<typename Tp::container_type> iter;
        iter = mapping_end(fix.container, 0);
        --iter; // When at the end, this call the 'maximum' function
        BOOST_REQUIRE_EQUAL((*iter)[0], max_value_0);
        iter = mapping_end(fix.container, 1); --iter;
        BOOST_REQUIRE_EQUAL((*iter)[1], max_value_1);
        fix.container.erase(iter);
      }
  }
  { // A tree where all elements are the same!
    Tp fix(100, same());
    // Prove that you can find the max value with N nodes, down to 1 nodes
    while (!fix.container.empty())
      {
        unsigned int count = 0;
        for(typename Tp::container_type::iterator
              i = fix.container.begin(); i != fix.container.end(); ++i)
          { ++count; }
        BOOST_CHECK_EQUAL(count, fix.container.size());
        mapping_iterator<typename Tp::container_type> iter;
        iter = mapping_end(fix.container, 0); --iter;
        BOOST_CHECK_EQUAL((*iter)[0], 100);
        iter = mapping_end(fix.container, 1); --iter;
        BOOST_CHECK_EQUAL((*iter)[1], 100);
        fix.container.erase(iter);
      }
  }
  { // test at the limit: a tree with 1 element
    Tp fix(1, same());
    mapping_iterator<const typename Tp::container_type> iter;
    iter = mapping_cend(fix.container, 0); --iter;
    BOOST_CHECK_EQUAL((*iter)[0], 1); // should be (1, 1);
    BOOST_CHECK_EQUAL((*iter)[1], 1);
    iter = mapping_cend(fix.container, 1); --iter;
    BOOST_CHECK_EQUAL((*iter)[0], 1); // should be (1, 1);
    BOOST_CHECK_EQUAL((*iter)[1], 1);
  }
  { // test at the limit: an unbalanced tree!
    Tp fix(100, decrease());
    mapping_iterator<typename Tp::container_type> iter;
    iter = mapping_end(fix.container, 0); --iter;
    BOOST_CHECK_EQUAL((*iter)[0], 100); // should be (100, 100);
    BOOST_CHECK_EQUAL((*iter)[1], 100);
  }
  { // test at the limit: an unbalanced tree!
    Tp fix(100, increase());
    mapping_iterator<typename Tp::container_type> iter;
    iter = mapping_end(fix.container, 1); --iter;
    BOOST_CHECK_EQUAL((*iter)[0], 99); // should be (99, 99);
    BOOST_CHECK_EQUAL((*iter)[1], 99);
  }
}