本文整理汇总了C++中Site::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Site::begin方法的具体用法?C++ Site::begin怎么用?C++ Site::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClassifySite
/*
* Given a site with known fluidness, examine the links to not-yet-visited
* neighbouring sites. If the neighbours have unknown fluidness, set that.
*
* Since we wish to examine each link only once, this will set link properties
* from neighbour => site as well as site => neighbour
*
*/
void CylinderGenerator::ClassifySite(Site& site) {
for (LaterNeighbourIterator neighIt = site.begin(); neighIt != site.end();
++neighIt) {
Site& neigh = *neighIt;
unsigned int iNeigh = neighIt.GetNeighbourIndex();
int nHits;
if (!neigh.IsFluidKnown) {
neigh.IsFluidKnown = true;
neigh.IsFluid = IsInsideCylinder(this->Cylinder, neigh.Position);
if (neigh.IsFluid)
neigh.CreateLinksVector();
}
// Four cases: fluid-fluid, solid-solid, fluid-solid and solid-fluid.
// Will handle the last two together.
if (site.IsFluid == neigh.IsFluid) {
if (site.IsFluid) {
// Fluid-fluid, must set CUT_NONE for both
site.Links[iNeigh].Type = geometry::CUT_NONE;
neigh.Links[Neighbours::inverses[iNeigh]].Type =
geometry::CUT_NONE;
} else {
// solid-solid, nothing to do.
}
} else {
// They differ, figure out which is fluid and which is solid.
Site* fluid;
Site* solid;
// Index of the solid site from the fluid site.
int iSolid;
if (site.IsFluid) {
fluid = &site;
solid = &neigh;
iSolid = iNeigh;
} else {
fluid = &neigh;
solid = &site;
iSolid = Neighbours::inverses[iNeigh];
}
// This uses special knowledge about the fact that we're working
// on a cylinder. Since the first point is always fluid, and the
// second always solid, we must get exactly one hit.
Hit hit = ComputeIntersection(this->Cylinder, this->Iolets, *fluid,
*solid);
LinkData& link = fluid->Links[iSolid];
// This is set in any solid case
float distanceInVoxels = (hit.pt - fluid->Position).GetMagnitude();
// The distance is in voxels but must be output as a fraction of
// the lattice vector. Scale it.
link.Distance = distanceInVoxels / Neighbours::norms[iSolid];
if (hit.cellId < 0) {
// -1 => we hit a wall
link.Type = geometry::CUT_WALL;
} else {
// We hit an inlet or outlet
Iolet* iolet = this->Iolets[hit.cellId];
if (iolet->IsInlet) {
link.Type = geometry::CUT_INLET;
} else {
link.Type = geometry::CUT_OUTLET;
}
// Set the Id
link.IoletId = iolet->Id;
}
// If this link intersected the wall, store the normal of the cell we hit and the distance to it.
if (link.Type == geometry::CUT_WALL) {
this->ComputeCylinderNormalAtAPoint(link.WallNormalAtWallCut,
hit.pt, this->Cylinder->Axis);
link.DistanceInVoxels = distanceInVoxels;
}
}
}
// If there's enough information available, an approximation of the wall normal will be computed for this fluid site.
this->ComputeAveragedNormal(site);
}
示例2: ClassifySite
/*
* Given a site with known fluidness, examine the links to not-yet-visited
* neighbouring sites. If the neighbours have unknown fluidness, set that.
*
* Since we wish to examine each link only once, this will set link properties
* from neighbour => site as well as site => neighbour
*
*/
void PolyDataGenerator::ClassifySite(Site& site) {
if (!site.IsFluidKnown){
throw GenerationErrorMessage("The start site is not known cannot continue");
}
for (LaterNeighbourIterator neighIt = site.begin(); neighIt != site.end();
++neighIt) {
Site& neigh = *neighIt;
unsigned int iNeigh = neighIt.GetNeighbourIndex();
int nHits = Intersect(site,neigh);
// Four cases: fluid-fluid, solid-solid, fluid-solid and solid-fluid.
// Will handle the last two together.
if (site.IsFluid == neigh.IsFluid) {
if (site.IsFluid) {
// Fluid-fluid, must set CUT_NONE for both
site.Links[iNeigh].Type = geometry::CUT_NONE;
neigh.Links[Neighbours::inverses[iNeigh]].Type =
geometry::CUT_NONE;
} else {
// solid-solid, nothing to do.
}
} else {
// They differ, figure out which is fluid and which is solid.
Site* fluid;
Site* solid;
// Index of the solid site from the fluid site.
int iSolid;
// Index of the point in this->hitPoints we're considering as the
// hit of interest (i.e. the one closest to the fluid site).
int iHit;
Vector hitPoint;
PointCGAL hitPointCGAL;
SegmentCGAL hitsegmentCGAL;
int hitCellId;
double distancetol = 0.01;
std::vector<int> CloseIoletIDS;
if (nHits == -1){//unclassified intersection need to be carefull.
if (site.IsFluid) {
fluid = &site;
solid = &neigh;
iSolid = iNeigh;
int n=0;
iHit = n;
// here we iterate over all intersections until we
// find a wall or the rest are futher away than the tol.
for (std::vector<Object_Primitive_and_distance>::iterator distit
= IntersectionCGAL.begin(); distit != IntersectionCGAL.end(); ++distit){
if (distit->second > IntersectionCGAL[0].second+distancetol){
iHit = n;
break;
}
int tempioletId = distit->first.second->id() - 2;
//shifting back from unsigned
if (tempioletId < 0){
break;//hit a wall no need to continue.
}//what if we hit both an inlet and outlet. Can that ever happen?
++n;
}
} else {
fluid = &neigh;
solid = &site;
iSolid = Neighbours::inverses[iNeigh];
int n = IntersectionCGAL.size()-1;
iHit = n;
for (std::vector<Object_Primitive_and_distance>::reverse_iterator distit
= IntersectionCGAL.rbegin(); distit != IntersectionCGAL.rend(); ++distit){
if (distit->second < IntersectionCGAL.back().second - distancetol){
iHit = n;
break;//ignoring the following intersections, they are to far away.
}
int tempioletId = distit->first.second->id() - 2; //shifting back from unsigned
if (tempioletId < 0){
break;//hit a wall no need to continue.
}//what if we hit both an inlet and outlet. Can that ever happen?
--n;
}
}
}
else{//normal intersection just take the closest point.
if (site.IsFluid) {
fluid = &site;
solid = &neigh;
iSolid = iNeigh;
iHit = 0;
} else {
fluid = &neigh;
solid = &site;
iSolid = Neighbours::inverses[iNeigh];
iHit = nHits - 1;
//.........这里部分代码省略.........