当前位置: 首页>>代码示例>>C++>>正文


C++ ModelObject类代码示例

本文整理汇总了C++中ModelObject的典型用法代码示例。如果您正苦于以下问题:C++ ModelObject类的具体用法?C++ ModelObject怎么用?C++ ModelObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ModelObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: myfunc_nlopt_gen

/// Objective function: calculates the objective value (ignore gradient calculation)
/// Keep track of how many times this function has been called, and report current
/// chi^2 (or other objective-function value) every 20 calls
/// Note that parameters n and grad are unused, but required by the NLopt interface.
double myfunc_nlopt_gen( unsigned n, const double *x, double *grad, void *my_func_data )
{
  ModelObject *theModel = (ModelObject *)my_func_data;
  // following is a necessary kludge bcs theModel->GetFitStatistic() won't accept 
  // const double*
  double  *params = (double *)x;
  double  fitStatistic;
  nlopt_result  junk;
  
  fitStatistic = theModel->GetFitStatistic(params);
  
  // feedback to user
  funcCallCount++;
  if (verboseOutput > 0) {
    if ((funcCallCount % FUNCS_PER_REPORTING_STEP) == 0) {
      printf("\tN-M simplex: function call %d: objective = %f\n", funcCallCount, fitStatistic);
      if ( (verboseOutput > 1) && ((funcCallCount % (REPORT_STEPS_PER_VERBOSE_OUTPUT*FUNCS_PER_REPORTING_STEP)) == 0) ) {
        PrintParametersSimple(theModel, params);
      }
    }
  }
  
  if (isnan(fitStatistic)) {
    fprintf(stderr, "\n*** NaN-valued fit statistic detected (N-M optimization)!\n");
    fprintf(stderr, "*** Terminating the fit...\n");
    junk = nlopt_force_stop(theOptimizer);
  }

  return(fitStatistic);
}
开发者ID:perwin,项目名称:imfit,代码行数:34,代码来源:nlopt_fit.cpp

示例2: MK_ASSERT

void Level::findObjectsInRadius( TGameObjectVec& out_objects, const rtti::TypeInfo* type, const mkVec3& search_origin, float radius, bool allow_derived /*= true*/ )
{
    MK_ASSERT(out_objects.empty());

    m_objectsMgr.findObjectsOfType(out_objects, type, allow_derived);

    for (size_t i = 0; i < out_objects.size(); ++i)
    {
        bool accept = false;

        GameObject* go = out_objects[i];
        if (go->getTypeInfo()->isDerivedOrExact(&ModelObject::Type))
        {
            ModelObject* mo = static_cast<ModelObject*>(go);
            float dist_sq = (mo->getWorldPosition() - search_origin).length();

            if (dist_sq <= radius)
                accept = true;
        }

        if (!accept)
            out_objects[i] = NULL;
    }

    fast_remove_val_from_vec(out_objects, (GameObject*)NULL);
}
开发者ID:KamilLelonek,项目名称:frail_pwr,代码行数:26,代码来源:Level.cpp

示例3: IsOverlapping

bool Model::IsOverlapping(ModelObject &left, ModelObject &right)
{
  Shape::Sphere circle_left = { left.position(), left.radius() };
  Shape::Sphere circle_right = { right.position(), right.radius() };

  return (Overlap::IsOverlapping(circle_left, circle_right));
}
开发者ID:rLadia,项目名称:NBodySimulator,代码行数:7,代码来源:model.cpp

示例4:

// Set parent object id (after reading from model emf-file)
void
BoundaryCondition::updateParentId()
{
  // If parent object type is a normal boundary, replace the
  // parent object with the boundary-group object
  //
  if ( parentEmfType != OT_ELEMENT_GROUP ) {

    ModelObject* obj = model->getModelObjectByTag(parentEmfType, parentEmfTag);
    if ( obj != NULL ) {
      BodyElement* be = (BodyElement*)obj;
      parentEmfTag = be->getElementGroupTag();
      parentEmfType = OT_ELEMENT_GROUP;
    } else {
      parentEmfTag = NO_INDEX;
      parentEmfType = OT_NONE;
    }
  }

  ModelObject* obj = model->getModelObjectByTag(parentEmfType, parentEmfTag);

  if ( obj != NULL ) {
    parentId = obj->Id();
  }
}
开发者ID:SangitaSingh,项目名称:elmerfem,代码行数:26,代码来源:ecif_boundaryCondition.cpp

示例5: ModelObject

void RenderQueue::Enqueue(const mat4x4 &world, ModelHandle& model){
	ModelObject* obj = new ModelObject();
	obj->Model = model;
	obj->World = world;
	obj->SetType( RENDER_TYPE::MODEL);
	m_CurrentScene->Objects.push_back(obj);
	m_CurrentScene->Programs.push_back(nullptr); //default program
}
开发者ID:exnotime,项目名称:KlurifaxRay,代码行数:8,代码来源:RenderQueue.cpp

示例6: clone

 ModelObject ParentObject_Impl::clone(Model model) const
 {
   ModelObject newParentAsModelObject = ModelObject_Impl::clone(model);
   ParentObject newParent = newParentAsModelObject.cast<ParentObject>();
   for (ModelObject child : children())
   {
     ModelObject newChild = child.clone(model);
     newChild.setParent(newParent);
   }
   return newParentAsModelObject;
 }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:11,代码来源:ParentObject.cpp

示例7: TEST_F

TEST_F(ModelFixture, Construction_Clone)
{
  Model library;

  // Create some materials
  StandardOpaqueMaterial exterior(library);
  AirGap air(library);
  StandardOpaqueMaterial interior(library);

  OpaqueMaterialVector layers;
  layers.push_back(exterior);
  layers.push_back(air);
  layers.push_back(interior);

  EXPECT_EQ(static_cast<unsigned>(3), library.getModelObjects<Material>().size());

  Construction construction(layers);
  ASSERT_EQ(static_cast<unsigned>(3), construction.layers().size());

  // Clone into same model
  ModelObject clone = construction.clone(library);

  // Material ResourceObject instances are shared resources so they have not been cloned
  EXPECT_EQ(static_cast<unsigned>(3), library.getModelObjects<Material>().size());

  // New handle for cloned construction
  EXPECT_FALSE(clone.handle() == construction.handle());
  ASSERT_TRUE(clone.optionalCast<Construction>());

  ASSERT_EQ(static_cast<unsigned>(3), clone.cast<Construction>().layers().size());

  // Clone into a differnt model
  Model model;

  auto clone2 = construction.clone(model).cast<Construction>();
  EXPECT_EQ(static_cast<unsigned>(3), model.getModelObjects<Material>().size());

  EXPECT_EQ(static_cast<unsigned>(1), model.getModelObjects<Construction>().size());

  // Make sure materials are still hooked up
  ASSERT_EQ(static_cast<unsigned>(3), clone2.cast<Construction>().layers().size());

  // Clone again
  auto clone3 = construction.clone(model).cast<Construction>();
  EXPECT_EQ(static_cast<unsigned>(3), model.getModelObjects<Material>().size());

  EXPECT_EQ(static_cast<unsigned>(2), model.getModelObjects<Construction>().size());

  // Make sure materials are still hooked up
  ASSERT_EQ(static_cast<unsigned>(3), clone3.cast<Construction>().layers().size());

  EXPECT_FALSE(clone2.handle() == clone3.handle());
}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:53,代码来源:Construction_GTest.cpp

示例8: get_output_containers

ContainersTemp get_output_containers(const ModelObjectsTemp &mo) {
  ContainersTemp ret;
  for (unsigned int i = 0; i < mo.size(); ++i) {
    ModelObject *o = mo[i];
    Container *p = dynamic_cast<Container *>(o);
    if (p)
      ret.push_back(p);
    else {
      ret += get_output_containers(o->get_inputs());
    }
  }
  return ret;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:13,代码来源:ModelObject.cpp

示例9: get_output_particles

ParticlesTemp get_output_particles(const ModelObjectsTemp &mo) {
  ParticlesTemp ret;
  for (unsigned int i = 0; i < mo.size(); ++i) {
    ModelObject *o = mo[i];
    Particle *p = dynamic_cast<Particle *>(o);
    if (p)
      ret.push_back(p);
    else {
      ret += get_output_particles(o->get_inputs());
    }
  }
  return ret;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:13,代码来源:ModelObject.cpp

示例10: refreshTextAndLabel

void OSIntegerEdit::refreshTextAndLabel() {
  if (m_modelObject) {
    QString textValue;
    ModelObject modelObject = m_modelObject.get();
    std::stringstream ss;

    if (m_isAutosizedProperty) {
      Attribute autosized = modelObject.getAttribute(*m_isAutosizedProperty).get();
      if (autosized.valueAsBoolean()) {
        textValue = QString("autosize");
      }
    }

    if (m_isAutocalculatedProperty) {
      Attribute autocalculated = modelObject.getAttribute(*m_isAutocalculatedProperty).get();
      if (autocalculated.valueAsBoolean()) {
        textValue = QString("autocalculate");
      }
    }

    OptionalAttribute attribute = modelObject.getAttribute(m_property);
    if (attribute) {
      int value = attribute->valueAsInteger();
      if (m_isScientific) {
        ss << std::scientific;
      }
      else {
        ss << std::fixed;
      }
      if (m_precision) {
        ss << std::setprecision(*m_precision);
      }
      ss << value;
      textValue = toQString(ss.str());
      ss.str("");
    }

    this->setText(textValue);

    if (m_isDefaultedProperty) {
      Attribute defaulted = modelObject.getAttribute(*m_isDefaultedProperty).get();
      if (defaulted.valueAsBoolean()) {
        this->setStyleSheet("color:green");
      }
      else {
        this->setStyleSheet("color:black");
      }
    }
  }
}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:50,代码来源:OSIntegerEdit.cpp

示例11: isConnected

  bool Node_Impl::isConnected(const ModelObject & modelObject)
  {
    if( auto mo = outletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }
    if( auto mo = inletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }

    return false;
  }
开发者ID:urbanengr,项目名称:OpenStudio,代码行数:15,代码来源:Node.cpp

示例12: TEST_F

TEST_F(ModelFixture, ModelObject_Attributes)
{
  Model model;

  OptionalWorkspaceObject oObject = model.addObject(IdfObject(IddObjectType::OS_Version));
  ASSERT_TRUE(oObject);
  ModelObject version = oObject->cast<ModelObject>();
  StringVector versionAttributeNames = version.attributeNames();
  ASSERT_EQ(static_cast<unsigned>(3),versionAttributeNames.size());
  EXPECT_EQ("iddObjectType",versionAttributeNames[0]);
  EXPECT_EQ("handle",versionAttributeNames[1]);
  EXPECT_EQ("name",versionAttributeNames[2]);

  EXPECT_FALSE(version.getAttribute("N a m e"));
}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:15,代码来源:ModelObject_GTest.cpp

示例13: coolingPriority

unsigned ZoneHVACEquipmentList_Impl::coolingPriority(const ModelObject & equipment)
{
  boost::optional<unsigned> result;

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == equipment.handle() )
    {
      result = it->getUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence);

      break;
    }
  }

  OS_ASSERT(result);

  return result.get();
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:26,代码来源:ZoneHVACEquipmentList.cpp

示例14: getGroupForModelObject

WorkspaceExtensibleGroup ZoneHVACEquipmentList_Impl::getGroupForModelObject(const ModelObject & modelObject)
{
  boost::optional<WorkspaceExtensibleGroup> result;

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == modelObject.handle() )
    {
      result = it->cast<WorkspaceExtensibleGroup>();

      break;
    }
  }

  OS_ASSERT(result);

  return result.get();
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:26,代码来源:ZoneHVACEquipmentList.cpp

示例15: ModelObject

ExternalInterfaceFunctionalMockupUnitImportToActuator::ExternalInterfaceFunctionalMockupUnitImportToActuator(const ModelObject& modelObject,
                                                                                                             const std::string& actuatedComponentType,
                                                                                                             const std::string& actuatedComponentControlType,
                                                                                                             const ExternalInterfaceFunctionalMockupUnitImport& fMUFile,
                                                                                                             const std::string& fMUInstanceName,
                                                                                                             const std::string& fMUVariableName,
                                                                                                             double initialValue)
  : ModelObject(ExternalInterfaceFunctionalMockupUnitImportToActuator::iddObjectType(), modelObject.model())
{
  OS_ASSERT(getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToActuator_Impl>());

  bool ok = setActuatedComponentUnique(modelObject);
  if (!ok) {
    remove();
    LOG_AND_THROW("Unable to set " << briefDescription() << "'s ActuatedComponentUnique to "
      << modelObject.nameString() << ".");
  }
  setActuatedComponentType(actuatedComponentType);
  setActuatedComponentControlType(actuatedComponentControlType);
  ok = setFMUFile(fMUFile);
  if (!ok) {
    remove();
    LOG_AND_THROW("Unable to set " << briefDescription() << "'s FMUFileName to "
      << fMUFile.fMUFileName() << ".");
  }
  setFMUInstanceName(fMUInstanceName);
  setFMUVariableName(fMUVariableName);
  setInitialValue(initialValue);
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:29,代码来源:ExternalInterfaceFunctionalMockupUnitImportToActuator.cpp


注:本文中的ModelObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。