本文整理汇总了C++中contour函数的典型用法代码示例。如果您正苦于以下问题:C++ contour函数的具体用法?C++ contour怎么用?C++ contour使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了contour函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contour
void MapgenV7::generateCaves(s16 max_stone_y)
{
if (max_stone_y >= node_min.Y) {
u32 index = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; x++, i++, index++) {
float d1 = contour(noise_cave1->result[index]);
float d2 = contour(noise_cave2->result[index]);
if (d1 * d2 > 0.3) {
content_t c = vm->m_data[i].getContent();
if (!ndef->get(c).is_ground_content || c == CONTENT_AIR)
continue;
vm->m_data[i] = MapNode(CONTENT_AIR);
}
}
}
}
PseudoRandom ps(blockseed + 21343);
u32 bruises_count = (ps.range(1, 4) == 1) ? ps.range(1, 2) : 0;
for (u32 i = 0; i < bruises_count; i++) {
CaveV7 cave(this, &ps);
cave.makeCave(node_min, node_max, max_stone_y);
}
}
示例2: contour
void MapgenFractal::generateCaves(s16 max_stone_y)
{
if (max_stone_y < node_min.Y)
return;
noise_cave1->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
noise_cave2->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
v3s16 em = vm->m_area.getExtent();
u32 index2d = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
bool column_is_open = false; // Is column open to overground
u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
(x - node_min.X);
// Biome of column
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]);
for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
content_t c = vm->m_data[vi].getContent();
if (c == CONTENT_AIR || c == biome->c_water_top ||
c == biome->c_water) {
column_is_open = true;
continue;
}
// Ground
float d1 = contour(noise_cave1->result[index3d]);
float d2 = contour(noise_cave2->result[index3d]);
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
// In tunnel and ground content, excavate
vm->m_data[vi] = MapNode(CONTENT_AIR);
} else if (column_is_open &&
(c == biome->c_filler || c == biome->c_stone)) {
// Tunnel entrance floor
vm->m_data[vi] = MapNode(biome->c_top);
column_is_open = false;
} else {
column_is_open = false;
}
}
}
if (node_max.Y > MGFRACTAL_LARGE_CAVE_DEPTH)
return;
PseudoRandom ps(blockseed + 21343);
u32 bruises_count = ps.range(0, 2);
for (u32 i = 0; i < bruises_count; i++) {
CaveV5 cave(this, &ps);
cave.makeCave(node_min, node_max, max_stone_y);
}
}
示例3: pr
void OreVein::generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, u8 *biomemap)
{
PcgRandom pr(blockseed + 520);
MapNode n_ore(c_ore, 0, ore_param2);
u32 sizex = (nmax.X - nmin.X + 1);
if (!noise) {
int sx = nmax.X - nmin.X + 1;
int sy = nmax.Y - nmin.Y + 1;
int sz = nmax.Z - nmin.Z + 1;
noise = new Noise(&np, mapseed, sx, sy, sz);
noise2 = new Noise(&np, mapseed + 436, sx, sy, sz);
}
bool noise_generated = false;
size_t index = 0;
for (int z = nmin.Z; z <= nmax.Z; z++)
for (int y = nmin.Y; y <= nmax.Y; y++)
for (int x = nmin.X; x <= nmax.X; x++, index++) {
u32 i = vm->m_area.index(x, y, z);
if (!vm->m_area.contains(i))
continue;
if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
continue;
if (biomemap && !biomes.empty()) {
u32 bmapidx = sizex * (z - nmin.Z) + (x - nmin.X);
std::set<u8>::iterator it = biomes.find(biomemap[bmapidx]);
if (it == biomes.end())
continue;
}
// Same lazy generation optimization as in OreBlob
if (!noise_generated) {
noise_generated = true;
noise->perlinMap3D(nmin.X, nmin.Y, nmin.Z);
noise2->perlinMap3D(nmin.X, nmin.Y, nmin.Z);
}
// randval ranges from -1..1
float randval = (float)pr.next() / (pr.RANDOM_RANGE / 2) - 1.f;
float noiseval = contour(noise->result[index]);
float noiseval2 = contour(noise2->result[index]);
if (noiseval * noiseval2 + randval * random_factor < nthresh)
continue;
vm->m_data[i] = n_ore;
}
}
示例4: while
float CLevelGraph::check_position_in_direction(u32 start_vertex_id, const Fvector &start_position, const Fvector &finish_position, const float max_distance) const
{
SContour _contour;
const_iterator I,E;
int saved_index, iPrevIndex = -1, iNextNode;
Fvector start_point = start_position, temp_point = start_position, finish_point = finish_position;
float fCurDistance = 0.f, fDistance = start_position.distance_to_xz(finish_position);
u32 dwCurNode = start_vertex_id;
while (!inside(vertex(dwCurNode),finish_position) && (fCurDistance < (fDistance + EPS_L))) {
begin (dwCurNode,I,E);
saved_index = -1;
contour (_contour,dwCurNode);
for ( ; I != E; ++I) {
iNextNode = value(dwCurNode,I);
if (valid_vertex_id(iNextNode) && (iPrevIndex != iNextNode))
choose_point(start_point,finish_point,_contour, iNextNode,temp_point,saved_index);
}
if (saved_index > -1) {
fCurDistance = start_point.distance_to_xz(temp_point);
iPrevIndex = dwCurNode;
dwCurNode = saved_index;
}
else
return (max_distance);
}
if (inside(vertex(dwCurNode),finish_position) && (_abs(vertex_plane_y(*vertex(dwCurNode),finish_position.x,finish_position.z) - finish_position.y) < .5f))
return (start_point.distance_to_xz(finish_position));
else
return (max_distance);
}
示例5: displayPlanarRegions
void
displayPlanarRegions (std::vector<pcl::PlanarRegion<PointT>, Eigen::aligned_allocator<pcl::PlanarRegion<PointT> > > ®ions,
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer)
{
char name[1024];
unsigned char red [6] = {255, 0, 0, 255, 255, 0};
unsigned char grn [6] = { 0, 255, 0, 255, 0, 255};
unsigned char blu [6] = { 0, 0, 255, 0, 255, 255};
pcl::PointCloud<PointT>::Ptr contour (new pcl::PointCloud<PointT>);
for (size_t i = 0; i < regions.size (); i++)
{
Eigen::Vector3d centroid = regions[i].getCentroid ();
Eigen::Vector4d model = regions[i].getCoefficients ();
pcl::PointXYZ pt1 = pcl::PointXYZ (centroid[0], centroid[1], centroid[2]);
pcl::PointXYZ pt2 = pcl::PointXYZ (centroid[0] + (0.5 * model[0]),
centroid[1] + (0.5 * model[1]),
centroid[2] + (0.5 * model[2]));
sprintf (name, "normal_%d", unsigned (i));
viewer->addArrow (pt2, pt1, 1.0, 0, 0, false, name);
contour->points = regions[i].getContour ();
sprintf (name, "plane_%02d", int (i));
pcl::visualization::PointCloudColorHandlerCustom <PointT> color (contour, red[i%6], grn[i%6], blu[i%6]);
if(!viewer->updatePointCloud(contour, color, name))
viewer->addPointCloud (contour, color, name);
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5, name);
}
}
示例6: toCv
vector<cv::Point2f> toCv(const ofPolyline& polyline) {
vector<cv::Point2f> contour(polyline.size());
for(int i = 0; i < polyline.size(); i++) {
contour[i].x = polyline[i].x;
contour[i].y = polyline[i].y;
}
return contour;
}
示例7: build_graph
grace grace::contour(double (*fun)(double,double*),double x0,double x1,int nx,VTYPE &par)
{
double x[nx];
VTYPE y;
build_graph(x,y,fun,x0,x1,nx,par);
contour(x,y);
return *this;
}
示例8: pr
void OreVein::generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax)
{
PseudoRandom pr(blockseed + 520);
MapNode n_ore(c_ore, 0, ore_param2);
if (!noise) {
int sx = nmax.X - nmin.X + 1;
int sy = nmax.Y - nmin.Y + 1;
int sz = nmax.Z - nmin.Z + 1;
noise = new Noise(&np, mapseed, sx, sy, sz);
noise2 = new Noise(&np, mapseed + 436, sx, sy, sz);
}
bool noise_generated = false;
size_t index = 0;
for (int z = nmin.Z; z <= nmax.Z; z++)
for (int y = nmin.Y; y <= nmax.Y; y++)
for (int x = nmin.X; x <= nmax.X; x++, index++) {
u32 i = vm->m_area.index(x, y, z);
if (!vm->m_area.contains(i))
continue;
if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
continue;
// Same lazy generation optimization as in OreBlob
if (!noise_generated) {
noise_generated = true;
noise->perlinMap3D(nmin.X, nmin.Y, nmin.Z);
noise2->perlinMap3D(nmin.X, nmin.Y, nmin.Z);
}
// randval ranges from -1..1
float randval = (float)pr.next() / (PSEUDORANDOM_MAX / 2) - 1.f;
float noiseval = contour(noise->result[index]);
float noiseval2 = contour(noise2->result[index]);
if (noiseval * noiseval2 + randval * random_factor < nthresh)
continue;
vm->m_data[i] = n_ore;
}
}
示例9: contour
void MapgenV5::generateCaves(int max_stone_y)
{
if (max_stone_y < node_min.Y)
return;
noise_cave1->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
noise_cave2->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
u32 index = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 vi = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; x++, vi++, index++) {
// Don't excavate the overgenerated stone at node_max.Y + 1,
// this creates a 'roof' over the tunnel, preventing light in
// tunnels at mapchunk borders when generating mapchunks upwards.
if (y > node_max.Y)
continue;
float d1 = contour(noise_cave1->result[index]);
float d2 = contour(noise_cave2->result[index]);
if (d1 * d2 > 0.125f) {
content_t c = vm->m_data[vi].getContent();
if (!ndef->get(c).is_ground_content || c == CONTENT_AIR)
continue;
vm->m_data[vi] = MapNode(CONTENT_AIR);
}
}
}
if (node_max.Y > MGV5_LARGE_CAVE_DEPTH)
return;
PseudoRandom ps(blockseed + 21343);
u32 bruises_count = ps.range(0, 2);
for (u32 i = 0; i < bruises_count; i++) {
CaveV5 cave(this, &ps);
cave.makeCave(node_min, node_max, max_stone_y);
}
}
示例10: rotatedRectangleContainPoint
bool rotatedRectangleContainPoint(cv::RotatedRect rectangle, cv::Point2f point) {
cv::Point2f corners[4];
rectangle.points(corners);
cv::Point2f *lastItemPointer = (corners + sizeof corners / sizeof corners[0]);
std::vector<cv::Point2f> contour(corners, lastItemPointer);
double indicator = pointPolygonTest(contour, point, false);
return indicator >= 0;
}
示例11: contour
void MapgenV7::generateCaves(int max_stone_y)
{
if (max_stone_y >= node_min.Y) {
u32 index = 0;
u32 index2d = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++) {
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X;
x++, i++, index++, index2d++) {
float d1 = contour(noise_cave1->result[index]);
float d2 = contour(noise_cave2->result[index]);
if (d1 * d2 > 0.3) {
Biome *biome = (Biome *)bmgr->
getRaw(biomemap[index2d]);
content_t c = vm->m_data[i].getContent();
if (!ndef->get(c).is_ground_content ||
c == CONTENT_AIR ||
(y <= water_level &&
c != biome->c_stone &&
c != c_stone))
continue;
vm->m_data[i] = MapNode(CONTENT_AIR);
}
}
index2d -= ystride;
}
index2d += ystride;
}
}
PseudoRandom ps(blockseed + 21343);
u32 bruises_count = (ps.range(1, 4) == 1) ? ps.range(1, 2) : 0;
for (u32 i = 0; i < bruises_count; i++) {
CaveV7 cave(this, &ps);
cave.makeCave(node_min, node_max, max_stone_y);
}
}
示例12: testBrokenCurve
void testBrokenCurve() {
FTContour contour( brokenPoints, simpleConicTags, 3);
CPPUNIT_ASSERT( contour.PointCount() == 1);
FTContour shortContour( shortLine, simpleConicTags, 2);
CPPUNIT_ASSERT( shortContour.PointCount() == 6);
FTContour reallyShortContour( shortLine, simpleConicTags, 1);
CPPUNIT_ASSERT( reallyShortContour.PointCount() == 1);
FTContour brokenTagtContour( shortLine, brokenTags, 3);
CPPUNIT_ASSERT( brokenTagtContour.PointCount() == 7);
}
示例13: noise3d_param
double noise3d_param(const OldNoiseParams ¶m, double x, double y, double z)
{
double s = param.pos_scale;
x /= s;
y /= s;
z /= s;
if(param.type == OLDNOISE_CONSTANT_ONE)
{
return 1.0;
}
else if(param.type == OLDNOISE_PERLIN)
{
return param.noise_scale*noise3d_perlin(x,y,z, param.seed,
param.octaves,
param.persistence);
}
else if(param.type == OLDNOISE_PERLIN_ABS)
{
return param.noise_scale*noise3d_perlin_abs(x,y,z, param.seed,
param.octaves,
param.persistence);
}
else if(param.type == OLDNOISE_PERLIN_CONTOUR)
{
return contour(param.noise_scale*noise3d_perlin(x,y,z,
param.seed, param.octaves,
param.persistence));
}
else if(param.type == OLDNOISE_PERLIN_CONTOUR_FLIP_YZ)
{
return contour(param.noise_scale*noise3d_perlin(x,z,y,
param.seed, param.octaves,
param.persistence));
}
else assert(0);
}
示例14: contour
/******************************************************************
* Fonctions secondaires appelées lors de l'extraction de la moelle
******************************************************************/
uiCoord2D PithExtractor::transHough(const Slice &slice, int width, int height, int *x, int *y, int *sliceMaxValue, int *nbContourPoints) const
{
int x_accu, y_accu, longueur, min;
int *droite;
Slice *tabaccu;
arma::fmat *orientation, *cont;
uiCoord2D coordmax;
orientation = 0;
{ // bloc de limitation de vie de la variable voisinage
// attention x represente les colonne et y les lignes
const Slice &voisinage = slice.submat( *y, *x, (uint)( (*y)+height-1 ), (uint)( (*x)+width-1 ) );
cont = contour(voisinage, &orientation);
}
tabaccu = new Slice(width, height);
tabaccu->zeros();
//verifie orientation et table d'accumlation tous les points se trouvent a 0
*nbContourPoints = 0;
for(uint i=0; i<cont->n_rows; i++){
for(uint j=0; j<cont->n_cols; j++){
if((*cont)(i,j) == 1){
*nbContourPoints += 1;
droite = drawLine(j, i, (*orientation)(i,j), width, height, &longueur);
for(int k=0; k<longueur; k++){
y_accu = droite[k]/width;
x_accu = droite[k]-(y_accu*width);
(*tabaccu) (y_accu, x_accu) ++;
}
delete [] droite;
}
}
}
// std::cerr << "nbptcontour=" << * nbptcontour << "\n";
delete cont;
delete orientation;
//min et max globaux
min = *sliceMaxValue = (*tabaccu)(0,0);
coordmax.x = coordmax.y = 0;
minSlice(*tabaccu, &min, sliceMaxValue, &coordmax);
delete tabaccu;
*x += coordmax.x;
*y += coordmax.y;
return uiCoord2D(*x, *y);
}
示例15: leaf
QuadTreeNodeData::REGION_INTERSECTION_FLAG QuadTree::region_intersection(const iterator_base & it,
const std::vector<RS_Vector > & region_contour )
{
if(region_contour.size()<2) return QuadTreeNodeData::OUT_REGION;
const RS_Vector * _p_tr = it->tr();
const RS_Vector * _p_tl = it->tl();
const RS_Vector * _p_br = it->br();
const RS_Vector * _p_bl = it->bl();
//for rubset reasion
double eps = (*_p_tr - * _p_tl).x/100;
Poly leaf(Point(_p_bl->x, _p_bl->y));
leaf.add (Point(_p_br->x, _p_br->y));
leaf.add (Point(_p_tr->x, _p_tr->y));
leaf.add (Point(_p_tl->x, _p_tl->y));
Poly leaf_large(Point(_p_bl->x-eps, _p_bl->y-eps));
leaf_large.add (Point(_p_br->x+eps, _p_br->y-eps));
leaf_large.add (Point(_p_tr->x+eps, _p_tr->y+eps));
leaf_large.add (Point(_p_tl->x-eps, _p_tl->y+eps));
Poly contour(Point(region_contour[0].x, region_contour[0].y));
for(unsigned int n=1; n<region_contour.size(); ++n)
contour.add(Point(region_contour[n].x, region_contour[n].y));
if(intersect(leaf_large, contour))
{
return QuadTreeNodeData::INTERSECTION_REGION;
}
// no intersection point?
if(contour.has_point(Point(_p_bl->x, _p_bl->y)) && contour.has_point(Point(_p_tr->x, _p_tr->y)))
{
//assert(fabs(contour.area()) >= leaf.area());
return QuadTreeNodeData::IN_REGION;
}
if(leaf_large.has_point(Point(region_contour[0].x, region_contour[0].y)))
{
//assert(leaf.area() >= fabs(contour.area()));
return QuadTreeNodeData::COVER_REGION;
}
return QuadTreeNodeData::OUT_REGION;
}