本文整理汇总了C++中QualityMetric::get_metric_type方法的典型用法代码示例。如果您正苦于以下问题:C++ QualityMetric::get_metric_type方法的具体用法?C++ QualityMetric::get_metric_type怎么用?C++ QualityMetric::get_metric_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QualityMetric
的用法示例。
在下文中一共展示了QualityMetric::get_metric_type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_metric_type
QualityMetric::MetricType CompareMetric::get_metric_type() const
{
MetricType t1 = metric1->get_metric_type();
assert(metric2->get_metric_type() == t1);
return t1;
}
示例2: 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);
}
示例3: compute_analytical_gradient
/* virtual function reimplemented from QualityMetric. No doxygen doc needed. */
bool LPtoPTemplate::compute_analytical_gradient(PatchData &pd,
Vector3D *const &grad,
double &OF_val,
MsqError &err, size_t array_size)
{
MSQ_FUNCTION_TIMER( "LPtoPTemplate::compute_analytical_gradient" );
//initialize the scaling value
double scaling_value=1.0;
size_t num_elements=pd.num_elements();
size_t num_vertices=pd.num_vertices();
if( num_vertices!=array_size && array_size>0)
{
MSQ_SETERR(err)("Incorrect array size.", MsqError::INVALID_ARG);
return false;
}
MsqMeshEntity* elems=pd.get_element_array(err); MSQ_ERRZERO(err);
MsqVertex* vertices=pd.get_vertex_array(err); MSQ_ERRZERO(err);
bool qm_bool=true;
double QM_val;
OF_val = 0.;
size_t i;
int p1;
//Set currentQM to be quality metric (possibly composite) associated with the objective function
QualityMetric* currentQM = get_quality_metric();
if(currentQM==NULL) {
MSQ_SETERR(err)("LPtoPTemplate has NULL QualityMetric pointer.",MsqError::INVALID_STATE);
return false;
}
enum QualityMetric::MetricType qm_type=currentQM->get_metric_type();
if (qm_type!=QualityMetric::ELEMENT_BASED &&
qm_type!=QualityMetric::VERTEX_BASED) {
MSQ_SETERR(err)("Make sure MetricType is initialised"
"in concrete QualityMetric constructor.",
MsqError::INVALID_STATE);
return false;
}
// zeros out objective function gradient
for (i=0; i<num_vertices; ++i)
grad[i] =0;
// Computes objective function gradient for an element based metric
if(qm_type==QualityMetric::ELEMENT_BASED){
//if scaling, divid by num_elements
if(dividingByN){
if(num_elements<=0) {
MSQ_SETERR(err)("The number of elements should not be zero.",MsqError::INVALID_MESH);
return false;
}
scaling_value/=num_elements;
}
size_t e, ve;
size_t nfve; // num free vtx in element
size_t nve; // num vtx in element
MsqVertex* ele_free_vtces[MSQ_MAX_NUM_VERT_PER_ENT];
const size_t *ele_vtces_ind;
// loops over all elements.
for (e=0; e<num_elements; ++e) {
// stores the pointers to the free vertices within the element
// (using pointer arithmetic).
nfve = 0;
nve = elems[e].vertex_count();
ele_vtces_ind = elems[e].get_vertex_index_array();
for (ve=0; ve<nve; ++ve) {
if (vertices[ele_vtces_ind[ve]].is_free_vertex()) {
ele_free_vtces[nfve] = vertices + ele_vtces_ind[ve];
++nfve;
}
}
// Computes q and grad(q)
Vector3D grad_vec[MSQ_MAX_NUM_VERT_PER_ENT];
qm_bool = currentQM->compute_element_gradient(
pd, &elems[e],
ele_free_vtces,
grad_vec, nfve, QM_val, err);
if(MSQ_CHKERR(err) || !qm_bool) return false;
// computes p*|Q(e)|^{p-1}
QM_val = fabs(QM_val);
double QM_pow=1.0;
double factor;
if (pVal==1) factor=1;
else {
QM_pow=QM_val;
for (p1=1; p1<pVal-1; ++p1)
QM_pow*=QM_val;
factor = QM_pow * pVal;
}
//this scales the gradient
factor *= (scaling_value * get_negate_flag());
//.........这里部分代码省略.........