本文整理汇总了C++中SVector3::negate方法的典型用法代码示例。如果您正苦于以下问题:C++ SVector3::negate方法的具体用法?C++ SVector3::negate怎么用?C++ SVector3::negate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVector3
的用法示例。
在下文中一共展示了SVector3::negate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interior
int edge_normal
(const MVertex *const vertex, const int zoneIndex, const GEdge *const gEdge,
const CCon::FaceVector<MZoneBoundary<2>::GlobalVertexData<MEdge>::FaceDataB>
&faces, SVector3 &boNormal, const int onlyFace = -1)
{
double par=0.0;
// Note: const_cast used to match MVertex.cpp interface
if(!reparamMeshVertexOnEdge(const_cast<MVertex*>(vertex), gEdge, par)) return 1;
const SVector3 tangent(gEdge->firstDer(par));
// Tangent to the boundary face
SPoint3 interior(0., 0., 0.); // An interior point
SVector3 meshPlaneNormal(0.); // This normal is perpendicular to the
// plane of the mesh
// The interior point and mesh plane normal are computed from all elements in
// the zone.
int cFace = 0;
int iFace = 0;
int nFace = faces.size();
if ( onlyFace >= 0 ) {
iFace = onlyFace;
nFace = onlyFace + 1;
}
for(; iFace != nFace; ++iFace) {
if(faces[iFace].zoneIndex == zoneIndex) {
++cFace;
interior += faces[iFace].parentElement->barycenter();
// Make sure all the planes go in the same direction
//**Required?
SVector3 mpnt = faces[iFace].parentElement->getFace(0).normal();
if(dot(mpnt, meshPlaneNormal) < 0.) mpnt.negate();
meshPlaneNormal += mpnt;
}
}
interior /= cFace;
// Normal to the boundary edge (but unknown direction)
boNormal = crossprod(tangent, meshPlaneNormal);
boNormal.normalize();
// Direction vector from vertex to interior (inwards). The normal should
// point in the same direction.
if(dot(boNormal, SVector3(vertex->point(), interior)) < 0.)
boNormal.negate();
return 0;
}
示例2: if
//.........这里部分代码省略.........
}
}
}
} // Stupid triangles
} // End if face in zone
} // End loop over faces
// Duplicates are a possibility, remove
useGFace.sort();
useGFace.unique();
//--'useGFace' now contains the face entities that connect to vertex. A
// BC
//--patch will be written for each of them.
for(std::list<const GFace *>::const_iterator gFIt = useGFace.begin();
gFIt != useGFace.end(); ++gFIt) {
SPoint2 par;
if(!reparamMeshVertexOnFace(const_cast<MVertex *>(vertex), *gFIt,
par))
goto getNormalFromElements; // :P After all that!
SVector3 boNormal = (*gFIt)->normal(par);
SPoint3 interior(0., 0., 0.);
int cFace = 0;
const int nFace = faces.size();
for(int iFace = 0; iFace != nFace; ++iFace) {
if(faces[iFace].zoneIndex == zoneIndex) {
++cFace;
interior += faces[iFace].parentElement->barycenter();
}
}
interior /= cFace;
if(dot(boNormal, SVector3(vertex->point(), interior)) < 0.)
boNormal.negate();
zoneBoVec.push_back(
VertexBoundary(zoneIndex, (*gFIt)->tag(), boNormal,
const_cast<MVertex *>(vertex), vertIndex));
patch.add((*gFIt)->tag());
}
}
break;
case 2:
/*--------------------------------------------------------------------*
* The vertex exists on a face and belongs to only 1 BC patch.
*--------------------------------------------------------------------*/
{
const GFace *const gFace = static_cast<const GFace *>(ent);
SPoint2 par;
if(!reparamMeshVertexOnFace(const_cast<MVertex *>(vertex), gFace, par))
goto getNormalFromElements;
SVector3 boNormal = static_cast<const GFace *>(ent)->normal(par);
SPoint3 interior(0., 0., 0.);
int cFace = 0;
const int nFace = faces.size();
for(int iFace = 0; iFace != nFace; ++iFace) {
if(faces[iFace].zoneIndex == zoneIndex) {
++cFace;
interior += faces[iFace].parentElement->barycenter();
}
}
interior /= cFace;
if(dot(boNormal, SVector3(vertex->point(), interior)) < 0.)
示例3: meshPlaneNormal
//.........这里部分代码省略.........
VertexBoundary(zoneIndex, gEdge2->tag(), boNormal2,
const_cast<MVertex *>(vertex), vertIndex));
patch.add(gEdge2->tag());
}
else {
//--Write one patch
boNormal1 += boNormal2;
boNormal1 *= 0.5;
zoneBoVec.push_back(
VertexBoundary(zoneIndex, gEdge1->tag(), boNormal1,
const_cast<MVertex *>(vertex), vertIndex));
patch.addPair(gEdge1->tag(), gEdge2->tag());
}
} break;
default:
Msg::Error("Internal error based on 2-D boundary assumptions (file "
"\'MZoneBoundary.cpp'). Boundary vertices may be "
"incorrect");
break;
}
}
break;
case 1:
/*--------------------------------------------------------------------*
* The vertex exists on an edge and belongs to only 1 BC patch.
*--------------------------------------------------------------------*/
{
SVector3 boNormal;
if(edge_normal(vertex, zoneIndex, static_cast<const GEdge *>(ent),
faces, boNormal))
goto getNormalFromElements;
zoneBoVec.push_back(VertexBoundary(zoneIndex, ent->tag(), boNormal,
const_cast<MVertex *>(vertex),
vertIndex));
patch.add(ent->tag());
}
break;
default: goto getNormalFromElements;
}
}
return;
getNormalFromElements:;
/*--------------------------------------------------------------------*
* Geometry information cannot be used - generate normals from the
* elements
*--------------------------------------------------------------------*/
{
if(warnNormFromElem && normalSource == 1) {
Msg::Warning("Some or all boundary normals were determined from mesh "
"elements instead of from the geometry");
warnNormFromElem = false;
}
// The mesh plane normal is computed from all elements attached to the
// vertex
SVector3 meshPlaneNormal(0.); // This normal is perpendicular to the
// plane of the mesh
const int nFace = faces.size();
for(int iFace = 0; iFace != nFace; ++iFace) {
if(faces[iFace].zoneIndex == zoneIndex) {
// Make sure all the planes go in the same direction
//**Required?
SVector3 mpnt = faces[iFace].parentElement->getFace(0).normal();
if(dot(mpnt, meshPlaneNormal) < 0.) mpnt.negate();
meshPlaneNormal += mpnt;
}
}
// Sum the normals from each element. The tangent is computed from all
// faces in the zone attached to the vertex and is weighted by the length of
// the edge. Each tangent has to be converted independently into an
// inwards-pointing normal.
SVector3 boNormal(0.);
for(int iFace = 0; iFace != nFace; ++iFace) {
if(faces[iFace].zoneIndex == zoneIndex) {
const SVector3 tangent =
faces[iFace]
.parentElement->getEdge(faces[iFace].parentFace)
.tangent();
// Normal to the boundary (unknown direction)
SVector3 bnt = crossprod(tangent, meshPlaneNormal);
// Inwards normal
const SVector3 inwards(vertex->point(),
faces[iFace].parentElement->barycenter());
if(dot(bnt, inwards) < 0.) bnt.negate();
boNormal += bnt;
}
}
boNormal.normalize();
zoneBoVec.push_back(VertexBoundary(
zoneIndex, 0, boNormal, const_cast<MVertex *>(vertex), vertIndex));
patch.add(0);
}
}