本文整理汇总了C++中Pair::first方法的典型用法代码示例。如果您正苦于以下问题:C++ Pair::first方法的具体用法?C++ Pair::first怎么用?C++ Pair::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pair
的用法示例。
在下文中一共展示了Pair::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: angle
void frameFieldBackgroundMesh2D::eval_crossfield(double u, double v, STensor3 &cf)
{
double quadAngle = angle(u,v);
Pair<SVector3, SVector3> dirs = compute_crossfield_directions(u,v,quadAngle);
SVector3 n = crossprod(dirs.first(),dirs.second());
for (int i=0; i<3; i++) {
cf(i,0) = dirs.first()[i];
cf(i,1) = dirs.second()[i];
cf(i,2) = n[i];
}
// SVector3 t1,t2,n;
// GFace *face = dynamic_cast<GFace*>(gf);
// Pair<SVector3, SVector3> der = face->firstDer(SPoint2(u,v));
// SVector3 s1 = der.first();
// SVector3 s2 = der.second();
// n = crossprod(s1,s2);
// n.normalize();
// s1.normalize();
// s2=crossprod(n,s1);
// t1 = s1 * cos(quadAngle) + s2 * sin(quadAngle) ;
// t1.normalize();
// t2 = crossprod(n,t1);
// for (int i=0;i<3;i++){
// cf(i,0) = t1[i];
// cf(i,1) = t2[i];
// cf(i,2) = n[i];
// }
}
示例2: serializePositionOffset
static String serializePositionOffset(const Pair& offset, const Pair& other)
{
if ((offset.first()->getValueID() == CSSValueLeft && other.first()->getValueID() == CSSValueTop)
|| (offset.first()->getValueID() == CSSValueTop && other.first()->getValueID() == CSSValueLeft))
return offset.second()->cssText();
return offset.cssText();
}
示例3: applyValue
virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
{
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
Pair* pair = primitiveValue->getPairValue();
if (!pair || !pair->first() || !pair->second())
return;
Length radiusWidth;
Length radiusHeight;
if (pair->first()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
radiusWidth = Length(pair->first()->getDoubleValue(), Percent);
else
radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
if (pair->second()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
else
radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
int width = radiusWidth.value();
int height = radiusHeight.value();
if (width < 0 || height < 0)
return;
if (!width)
radiusHeight = radiusWidth; // Null out the other value.
else if (!height)
radiusWidth = radiusHeight; // Null out the other value.
LengthSize size(radiusWidth, radiusHeight);
setValue(selector->style(), size);
}
示例4: updateCornerRadiusWidthAndHeight
static inline void updateCornerRadiusWidthAndHeight(CSSPrimitiveValue* corner, String& width, String& height)
{
if (!corner)
return;
Pair* radius = corner->getPairValue();
width = radius->first() ? radius->first()->cssText() : String("0");
if (radius->second())
height = radius->second()->cssText();
}
示例5: mapFillYPosition
void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value)
{
if (value->isInitialValue()) {
layer->setYPosition(FillLayer::initialFillYPosition(layer->type()));
return;
}
if (!is<CSSPrimitiveValue>(*value))
return;
CSSPrimitiveValue* primitiveValue = downcast<CSSPrimitiveValue>(value);
Pair* pair = primitiveValue->getPairValue();
if (pair) {
ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY);
primitiveValue = pair->second();
}
Length length;
if (primitiveValue->isLength())
length = primitiveValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData());
else if (primitiveValue->isPercentage())
length = Length(primitiveValue->getDoubleValue(), Percent);
else if (primitiveValue->isCalculatedPercentageWithLength())
length = Length(primitiveValue->cssCalcValue()->createCalculationValue(m_resolver->state().cssToLengthConversionData()));
else
return;
layer->setYPosition(length);
if (pair)
layer->setBackgroundYOrigin(*(pair->first()));
}
示例6: crossprod
// returns the cross field as a pair of othogonal vectors (NOT in parametric coordinates, but real 3D coordinates)
Pair<SVector3, SVector3> frameFieldBackgroundMesh2D::compute_crossfield_directions(double u, double v,
double angle_current)
{
// get the unit normal at that point
GFace *face = dynamic_cast<GFace*>(gf);
if(!face) {
Msg::Error("Entity is not a face in background mesh");
return Pair<SVector3,SVector3>(SVector3(), SVector3());
}
Pair<SVector3, SVector3> der = face->firstDer(SPoint2(u,v));
SVector3 s1 = der.first();
SVector3 s2 = der.second();
SVector3 n = crossprod(s1,s2);
n.normalize();
SVector3 basis_u = s1;
basis_u.normalize();
SVector3 basis_v = crossprod(n,basis_u);
// normalize vector t1 that is tangent to gf at uv
SVector3 t1 = basis_u * cos(angle_current) + basis_v * sin(angle_current) ;
t1.normalize();
// compute the second direction t2 and normalize (t1,t2,n) is the tangent frame
SVector3 t2 = crossprod(n,t1);
t2.normalize();
return Pair<SVector3,SVector3>(SVector3(t1[0],t1[1],t1[2]),
SVector3(t2[0],t2[1],t2[2]));
}
示例7: Fopen
void frameFieldBackgroundMesh2D::exportCrossField(const std::string &filename)
{
FILE *f = Fopen(filename.c_str(), "w");
if(!f) {
Msg::Error("Could not open file '%s'", filename.c_str());
return;
}
fprintf(f,"View \"Cross Field\"{\n");
std::vector<double> deltas(2);
deltas[0] = 0.;
deltas[1] = M_PI;
for (std::vector<MVertex*>::iterator it = beginvertices(); it!=endvertices(); it++) {
MVertex *v = *it;
double angle_current = angle(v);
GPoint p = get_GPoint_from_MVertex(v);
for (int i=0; i<2; i++) {
Pair<SVector3, SVector3> dirs = compute_crossfield_directions(v->x(),v->y(),angle_current+deltas[i]);
fprintf(f,"VP(%g,%g,%g) {%g,%g,%g};\n",p.x(),p.y(),p.z(),dirs.first()[0], dirs.first()[1], dirs.first()[2]);
fprintf(f,"VP(%g,%g,%g) {%g,%g,%g};\n",p.x(),p.y(),p.z(),dirs.second()[0], dirs.second()[1], dirs.second()[2]);
}
}
fprintf(f,"};\n");
fclose(f);
}
示例8: mapFillYPosition
void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value)
{
if (value->isInitialValue()) {
layer->setYPosition(FillLayer::initialFillYPosition(layer->type()));
return;
}
if (!value->isPrimitiveValue())
return;
float zoomFactor = style()->effectiveZoom();
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
Pair* pair = primitiveValue->getPairValue();
if (pair) {
ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY);
primitiveValue = pair->second();
}
Length length;
if (primitiveValue->isLength())
length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor);
else if (primitiveValue->isPercentage())
length = Length(primitiveValue->getDoubleValue(), Percent);
else if (primitiveValue->isCalculatedPercentageWithLength())
length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor));
else if (primitiveValue->isViewportPercentageLength())
length = primitiveValue->viewportPercentageLength();
else
return;
layer->setYPosition(length);
if (pair)
layer->setBackgroundYOrigin(*(pair->first()));
}
示例9: mapNinePieceImageRepeat
void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, CSSValue* value, NinePieceImage& image)
{
if (!value || !value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (!pair || !pair->first() || !pair->second())
return;
CSSValueID firstIdentifier = pair->first()->getValueID();
CSSValueID secondIdentifier = pair->second()->getValueID();
ENinePieceImageRule horizontalRule;
switch (firstIdentifier) {
case CSSValueStretch:
horizontalRule = StretchImageRule;
break;
case CSSValueRound:
horizontalRule = RoundImageRule;
break;
case CSSValueSpace:
horizontalRule = SpaceImageRule;
break;
default: // CSSValueRepeat
horizontalRule = RepeatImageRule;
break;
}
image.setHorizontalRule(horizontalRule);
ENinePieceImageRule verticalRule;
switch (secondIdentifier) {
case CSSValueStretch:
verticalRule = StretchImageRule;
break;
case CSSValueRound:
verticalRule = RoundImageRule;
break;
case CSSValueSpace:
verticalRule = SpaceImageRule;
break;
default: // CSSValueRepeat
verticalRule = RepeatImageRule;
break;
}
image.setVerticalRule(verticalRule);
}
示例10:
const Pair<A,B>& Pair<A,B>::operator=(const Pair<A,B>& iP)
{
if (this!=&iP) {
_first=iP.first();
_second = iP.second();
}
return *this;
}
示例11: convertLengthPoint
LengthPoint StyleBuilderConverter::convertLengthPoint(StyleResolverState& state, CSSValue* value)
{
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
Length x = pair->first()->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
Length y = pair->second()->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
return LengthPoint(x, y);
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_WebKit,代码行数:8,代码来源:StyleBuilderConverter.cpp
示例12: convertToLengthSize
static LengthSize convertToLengthSize(const StyleResolverState& state, CSSPrimitiveValue* value)
{
if (!value)
return LengthSize(Length(0, Fixed), Length(0, Fixed));
Pair* pair = value->getPairValue();
return LengthSize(convertToLength(state, pair->first()), convertToLength(state, pair->second()));
}
示例13: computeMetricInfo
void highOrderTools::computeMetricInfo(GFace *gf,
MElement *e,
fullMatrix<double> &J,
fullMatrix<double> &JT,
fullVector<double> &D)
{
int nbNodes = e->getNumVertices();
// printf("ELEMENT --\n");
for (int j = 0; j < nbNodes; j++){
SPoint2 param;
reparamMeshVertexOnFace(e->getVertex(j), gf, param);
// printf("%g %g vs %g %g %g\n",param.x(),param.y(),
// e->getVertex(j)->x(),e->getVertex(j)->y(),e->getVertex(j)->z());
Pair<SVector3,SVector3> der = gf->firstDer(param);
int XJ = j;
int YJ = j + nbNodes;
int ZJ = j + 2 * nbNodes;
int UJ = j;
int VJ = j + nbNodes;
J(XJ,UJ) = der.first().x();
J(YJ,UJ) = der.first().y();
J(ZJ,UJ) = der.first().z();
J(XJ,VJ) = der.second().x();
J(YJ,VJ) = der.second().y();
J(ZJ,VJ) = der.second().z();
JT(UJ,XJ) = der.first().x();
JT(UJ,YJ) = der.first().y();
JT(UJ,ZJ) = der.first().z();
JT(VJ,XJ) = der.second().x();
JT(VJ,YJ) = der.second().y();
JT(VJ,ZJ) = der.second().z();
SVector3 ss = getSSL(e->getVertex(j));
GPoint gp = gf->point(param);
D(XJ) = (gp.x() - ss.x());
D(YJ) = (gp.y() - ss.y());
D(ZJ) = (gp.z() - ss.z());
}
}
示例14: convertRadius
LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSValue* value)
{
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
Length radiusWidth = pair->first()->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
Length radiusHeight = pair->second()->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
float width = radiusWidth.value();
float height = radiusHeight.value();
ASSERT(width >= 0 && height >= 0);
if (width <= 0 || height <= 0)
return LengthSize(Length(0, Fixed), Length(0, Fixed));
return LengthSize(radiusWidth, radiusHeight);
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_WebKit,代码行数:13,代码来源:StyleBuilderConverter.cpp
示例15: if
// Return the number of divisions in each direction for the face
Pair<label> faceNij(const label facei, const block& block)
{
Pair<label> fnij;
int i = facei/2;
if (i == 0)
{
fnij.first() = block.meshDensity().y() + 1;
fnij.second() = block.meshDensity().z() + 1;
}
else if (i == 1)
{
fnij.first() = block.meshDensity().x() + 1;
fnij.second() = block.meshDensity().z() + 1;
}
else if (i == 2)
{
fnij.first() = block.meshDensity().x() + 1;
fnij.second() = block.meshDensity().y() + 1;
}
return fnij;
}