本文整理汇总了C++中QualityMetric::evaluate_element方法的典型用法代码示例。如果您正苦于以下问题:C++ QualityMetric::evaluate_element方法的具体用法?C++ QualityMetric::evaluate_element怎么用?C++ QualityMetric::evaluate_element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QualityMetric
的用法示例。
在下文中一共展示了QualityMetric::evaluate_element方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: concrete_evaluate
bool LPtoPTemplate::concrete_evaluate(PatchData &pd, double &fval,
MsqError &err){
size_t index=0;
MsqMeshEntity* elems=pd.get_element_array(err);
bool obj_bool=true;
//double check for pVal=0;
if(pVal==0){
MSQ_SETERR(err)("pVal equal zero not allowed. L_0 is not a valid norm.",
MsqError::INVALID_STATE);
return false;
}
//Michael: this may not do what we want
//Set currentQM to be the first quality metric* in the list
QualityMetric* currentQM = get_quality_metric();
if(currentQM==NULL)
currentQM=get_quality_metric_list().front();
if(currentQM==NULL) {
MSQ_SETERR(err)("NULL QualityMetric pointer in LPtoPTemplate",
MsqError::INVALID_STATE);
return false;
}
size_t num_elements=pd.num_elements();
size_t num_vertices=pd.num_vertices();
size_t total_num=0;
if(currentQM->get_metric_type()==QualityMetric::ELEMENT_BASED)
total_num=num_elements;
else if (currentQM->get_metric_type()==QualityMetric::VERTEX_BASED)
total_num=num_vertices;
else {
MSQ_SETERR(err)("Make sure MetricType is initialised in concrete "
"QualityMetric constructor.", MsqError::INVALID_STATE);
return false;
}
msq_std::vector<double> metric_values(total_num);
if(currentQM->get_metric_type()==QualityMetric::ELEMENT_BASED)
{
for (index=0; index<num_elements;index++)
{
//if invalid return false after clean-up
obj_bool=currentQM->evaluate_element(pd, (&elems[index]),
metric_values[index], err);
if(MSQ_CHKERR(err) || !obj_bool){
fval=0.0;
return false;
}
metric_values[index]=fabs(metric_values[index]);
MSQ_DBGOUT(3) << " o Quality metric value for element "
<< index << "\t: " << metric_values[index] << "\n";
}
}
else if(currentQM->get_metric_type()==QualityMetric::VERTEX_BASED)
{
MsqVertex* vertices=pd.get_vertex_array(err); MSQ_ERRZERO(err);
for (index=0; index<num_vertices;index++)
{
//evaluate metric for this vertex
obj_bool=currentQM->evaluate_vertex(pd, (&vertices[index]),
metric_values[index], err);
//if invalid return false after clean-up
if(MSQ_CHKERR(err) || !obj_bool){
fval=0.0;
return false;
}
metric_values[index]=fabs(metric_values[index]);
}
}
fval=compute_function(&metric_values[0], total_num, err);
return !MSQ_CHKERR(err);
}