本文整理汇总了C++中Profiler::end方法的典型用法代码示例。如果您正苦于以下问题:C++ Profiler::end方法的具体用法?C++ Profiler::end怎么用?C++ Profiler::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profiler
的用法示例。
在下文中一共展示了Profiler::end方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
// profiler
Profiler profiler;
profiler.start((char*)"main");
// random generate 1d vector
// assign maximum size =>
const int max = 100;
vector<double> main_1d_points(max);
srand(time(NULL));
for (int i = 0; i < max; i++) {
main_1d_points[i] = rand() % 100;
};
// transform to Points, then sorting
Points main_points;
main_points.parse_1d_points_from(main_1d_points);
main_points.sort_by_y();
main_points.dump();
Points center;
center.create_center_from(main_points);
center.dump();
// create a set of points
Point a, b, c, d, e, f, g, h;
a.set_point( 0, 0);
b.set_point( 5, 0);
c.set_point( 5, 5);
d.set_point( 0, 5);
e.set_point(-5, 5);
f.set_point(-5, 0);
g.set_point(-5, -5);
h.set_point( 0, -5);
// form each segment
Segment ab, bc, cd, de, ef, fg, gh, ha;
ab.set_segment(&a, &b);
bc.set_segment(&b, &c);
cd.set_segment(&c, &d);
de.set_segment(&d, &e);
ef.set_segment(&e, &f);
fg.set_segment(&f, &g);
gh.set_segment(&g, &h);
ha.set_segment(&h, &a);
// try segment copy
Segment copy_test;
copy_test.copy(ab);
printf("copy segment:\n");
copy_test.dump();
copy_test.free();
// form a set of segments
Segments all;
all.append(&ab);
all.append(&bc);
all.append(&cd);
all.append(&de);
all.append(&ef);
all.append(&fg);
all.append(&gh);
all.append(&ha);
all.dump();
// set the set of segments to a polygon
// and test polygon function
Polygon polygon1;
polygon1.set_polygon(&all);
polygon1.dump();
printf("(%d) segments in this polygon\n", polygon1.get_segment_number());
printf("center point of this polygon is (%f, %f)\n",
polygon1.get_center().get_gx(),
polygon1.get_center().get_gy());
// set the set of segments to another polygon
// yet, they reference the same segments set
printf("\nthis is polygon2\n");
Polygon polygon2;
polygon2.set_polygon(&all);
polygon2.dump();
// try polygon copy
printf("\nthis is polygon3\n");
Polygon polygon3;
polygon3.copy(polygon2);
polygon3.dump();
// append the polygons into a set of polygons
Polygons polygons;
polygons.append(&polygon1);
polygons.append(&polygon3);
// set segment function and loop all polygons set
ktSetSegmentFunction(grow_45_degree);
ktLoopSegment(&polygons);
//.........这里部分代码省略.........
示例2: glGenTextures
void Viewport3D::updateVolumeTexture() {
if (!Segmentation::singleton().enabled) {
return;
}
auto& seg = Segmentation::singleton();
int texLen = seg.volume_tex_len;
if(seg.volume_tex_id == 0) {
glGenTextures(1, &seg.volume_tex_id);
glBindTexture(GL_TEXTURE_3D, seg.volume_tex_id);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, texLen, texLen, texLen, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
}
static Profiler tex_gen_profiler;
static Profiler dcfetch_profiler;
static Profiler colorfetch_profiler;
static Profiler occlusion_profiler;
static Profiler tex_transfer_profiler;
tex_gen_profiler.start(); // ----------------------------------------------------------- profiling
const auto currentPosDc = state->viewerState->currentPosition.cube(Dataset::current().cubeEdgeLength, Dataset::current().scaleFactor);
int cubeLen = Dataset::current().cubeEdgeLength;
int M = state->M;
int M_radius = (M - 1) / 2;
GLubyte* colcube = new GLubyte[4*texLen*texLen*texLen];
std::tuple<uint64_t, std::tuple<uint8_t, uint8_t, uint8_t, uint8_t>> lastIdColor;
state->protectCube2Pointer.lock();
dcfetch_profiler.start(); // ----------------------------------------------------------- profiling
uint64_t** rawcubes = new uint64_t*[M*M*M];
for(int z = 0; z < M; ++z)
for(int y = 0; y < M; ++y)
for(int x = 0; x < M; ++x) {
auto cubeIndex = z*M*M + y*M + x;
const CoordOfCube cubeCoordRelative{x - M_radius, y - M_radius, z - M_radius};
rawcubes[cubeIndex] = reinterpret_cast<uint64_t*>(cubeQuery(state->cube2Pointer
, Segmentation::singleton().layerId, Dataset::current().magIndex, currentPosDc + cubeCoordRelative));
}
dcfetch_profiler.end(); // ----------------------------------------------------------- profiling
colorfetch_profiler.start(); // ----------------------------------------------------------- profiling
for(int z = 0; z < texLen; ++z)
for(int y = 0; y < texLen; ++y)
for(int x = 0; x < texLen; ++x) {
Coordinate DcCoord{(x * M)/cubeLen, (y * M)/cubeLen, (z * M)/cubeLen};
auto cubeIndex = DcCoord.z*M*M + DcCoord.y*M + DcCoord.x;
auto& rawcube = rawcubes[cubeIndex];
if(rawcube != nullptr) {
auto indexInDc = ((z * M)%cubeLen)*cubeLen*cubeLen + ((y * M)%cubeLen)*cubeLen + (x * M)%cubeLen;
auto indexInTex = z*texLen*texLen + y*texLen + x;
auto subobjectId = rawcube[indexInDc];
if(subobjectId == std::get<0>(lastIdColor)) {
auto idColor = std::get<1>(lastIdColor);
colcube[4*indexInTex+0] = std::get<0>(idColor);
colcube[4*indexInTex+1] = std::get<1>(idColor);
colcube[4*indexInTex+2] = std::get<2>(idColor);
colcube[4*indexInTex+3] = std::get<3>(idColor);
} else if (seg.isSubObjectIdSelected(subobjectId)) {
auto idColor = seg.colorObjectFromSubobjectId(subobjectId);
std::get<3>(idColor) = 255; // ignore color alpha
colcube[4*indexInTex+0] = std::get<0>(idColor);
colcube[4*indexInTex+1] = std::get<1>(idColor);
colcube[4*indexInTex+2] = std::get<2>(idColor);
colcube[4*indexInTex+3] = std::get<3>(idColor);
lastIdColor = std::make_tuple(subobjectId, idColor);
} else {
colcube[4*indexInTex+0] = 0;
colcube[4*indexInTex+1] = 0;
colcube[4*indexInTex+2] = 0;
colcube[4*indexInTex+3] = 0;
}
} else {
auto indexInTex = z*texLen*texLen + y*texLen + x;
colcube[4*indexInTex+0] = 0;
colcube[4*indexInTex+1] = 0;
colcube[4*indexInTex+2] = 0;
colcube[4*indexInTex+3] = 0;
}
}
delete[] rawcubes;
state->protectCube2Pointer.unlock();
colorfetch_profiler.end(); // ----------------------------------------------------------- profiling
occlusion_profiler.start(); // ----------------------------------------------------------- profiling
for(int z = 1; z < texLen - 1; ++z)
for(int y = 1; y < texLen - 1; ++y)
for(int x = 1; x < texLen - 1; ++x) {
auto indexInTex = (z)*texLen*texLen + (y)*texLen + x;
//.........这里部分代码省略.........