本文整理汇总了C++中Paths::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Paths::clear方法的具体用法?C++ Paths::clear怎么用?C++ Paths::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paths
的用法示例。
在下文中一共展示了Paths::clear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromFile
bool LoadFromFile(Paths &ppg, char * filename, double scale= 1,
int xOffset = 0, int yOffset = 0)
{
ppg.clear();
FILE *f = fopen(filename, "r");
if (!f) return false;
int polyCnt, vertCnt;
char junk [80];
double X, Y;
if (fscanf(f, "%d", &polyCnt) == 1 && polyCnt > 0)
{
ppg.resize(polyCnt);
for (int i = 0; i < polyCnt; i++) {
if (fscanf(f, "%d", &vertCnt) != 1 || vertCnt <= 0) break;
ppg[i].resize(vertCnt);
for (int j = 0; j < vertCnt; j++) {
if (fscanf(f, "%lf%*[, ]%lf", &X, &Y) != 2) break;
ppg[i][j].X = Round((X + xOffset) * scale);
ppg[i][j].Y = Round((Y + yOffset) * scale);
fgets(junk, 80, f);
}
}
}
fclose(f);
return true;
}
示例2: to_polygons
static bool to_polygons(Paths &polygons, GB_ARRAY array)
{
int count;
CPOLYGON *p;
int i;
if (GB.CheckObject(array))
return true;
count = GB.Array.Count(array);
if (count == 0)
return false;
polygons.clear();
for(i = 0; i < count; i++)
{
p = *(CPOLYGON **)GB.Array.Get(array, i);
if (!p)
continue;
polygons.push_back(*(p->poly));
}
return false;
}
示例3: buildFromPaths
void TerraGenerator::buildFromPaths(Paths& paths, const RegionContext& regionContext)
{
foregroundClipper_.AddPaths(paths, ptSubject, true);
paths.clear();
foregroundClipper_.Execute(ctDifference, paths, pftNonZero, pftNonZero);
foregroundClipper_.moveSubjectToClip();
populateMesh(paths, regionContext);
}
示例4: Draw
//.........这里部分代码省略.........
if( m_bExclusionBoundary && !m_bInclusionBoundary ) {
// fill boundary with hatching
wxGraphicsContext *wxGC = NULL;
wxMemoryDC *pmdc = wxDynamicCast(dc.GetDC(), wxMemoryDC);
if( pmdc ) wxGC = wxGraphicsContext::Create( *pmdc );
else {
wxClientDC *pcdc = wxDynamicCast(dc.GetDC(), wxClientDC);
if( pcdc ) wxGC = wxGraphicsContext::Create( *pcdc );
}
wxGC->SetPen(*wxTRANSPARENT_PEN);
wxColour tCol;
tCol.Set(m_fillcol.Red(), m_fillcol.Green(), m_fillcol.Blue(), m_uiFillTransparency);
wxGC->SetBrush( *wxTheBrushList->FindOrCreateBrush( tCol, wxBRUSHSTYLE_CROSSDIAG_HATCH ) );
wxGraphicsPath path = wxGC->CreatePath();
path.MoveToPoint(m_bpts[0].x, m_bpts[0].y);
for( size_t i = 1; i < m_pODPointList->GetCount(); i++ )
{
path.AddLineToPoint(m_bpts[i].x, m_bpts[i].y);
}
path.CloseSubpath();
wxGC->StrokePath(path);
wxGC->FillPath( path );
delete wxGC;
} else if( !m_bExclusionBoundary && m_bInclusionBoundary && m_pODPointList->GetCount() > 3 ) {
// surround boundary with hatching if there is more than 10 pixels different between points
int l_imaxpointdiffX = 0;
int l_imaxpointdiffY = 0;
for( size_t i = 1; i < m_pODPointList->GetCount(); i++ ) {
int l_ipointdiffX = abs(m_bpts[0].x - m_bpts[i].x);
int l_ipointdiffY = abs(m_bpts[0].y - m_bpts[i].y);
if(l_ipointdiffX > l_imaxpointdiffX) l_imaxpointdiffX = l_ipointdiffX;
if(l_ipointdiffY > l_imaxpointdiffY) l_imaxpointdiffY = l_ipointdiffY;
}
if(l_imaxpointdiffX < 10 && l_imaxpointdiffY < 10 ) return;
// Use ClipperLib to manage Polygon
// If needed simplify polygons to make shading stay outside
Paths poly(1);
for( size_t i = 0; i < m_pODPointList->GetCount(); i++ ) {
poly[0] << IntPoint( m_bpts[i].x, m_bpts[i].y );
}
Paths polys;
SimplifyPolygons( poly, polys );
ClipperOffset co;
Paths ExpandedBoundaries;
co.AddPaths( polys, jtSquare, etClosedPolygon );
co.Execute( ExpandedBoundaries, m_iInclusionBoundarySize );
wxPoint *l_InclusionBoundary = new wxPoint[ ExpandedBoundaries[0].size() + 1 ];
for( size_t i = 0; i < ExpandedBoundaries[0].size(); i++ )
{
l_InclusionBoundary[i].x = ExpandedBoundaries[0][i].X;
l_InclusionBoundary[i].y = ExpandedBoundaries[0][i].Y;
}
// need to add first point to end to ensure the polygon is closed
l_InclusionBoundary[ ExpandedBoundaries[0].size()].x = ExpandedBoundaries[0][0].X;
l_InclusionBoundary[ ExpandedBoundaries[0].size()].y = ExpandedBoundaries[0][0].Y;
int *l_iPolygonPointCount = new int[2];
l_iPolygonPointCount[0] = m_pODPointList->GetCount();
l_iPolygonPointCount[1] = ExpandedBoundaries[0].size() + 1;
wxGraphicsContext *wxGC = NULL;
wxMemoryDC *pmdc = wxDynamicCast(dc.GetDC(), wxMemoryDC);
if( pmdc ) wxGC = wxGraphicsContext::Create( *pmdc );
else {
wxClientDC *pcdc = wxDynamicCast(dc.GetDC(), wxClientDC);
if( pcdc ) wxGC = wxGraphicsContext::Create( *pcdc );
}
wxGC->SetPen(*wxTRANSPARENT_PEN);
wxColour tCol;
tCol.Set(m_fillcol.Red(), m_fillcol.Green(), m_fillcol.Blue(), m_uiFillTransparency);
wxGC->SetBrush( *wxTheBrushList->FindOrCreateBrush( tCol, wxBRUSHSTYLE_CROSSDIAG_HATCH ) );
wxGraphicsPath path = wxGC->CreatePath();
path.MoveToPoint(m_bpts[0].x, m_bpts[0].y);
for( int i = 0; i < l_iPolygonPointCount[0]; i++ ) {
path.AddLineToPoint(m_bpts[i].x, m_bpts[i].y);
}
path.MoveToPoint(l_InclusionBoundary[0].x, l_InclusionBoundary[0].y);
for( int i = 1; i < l_iPolygonPointCount[1]; i++ ) {
path.AddLineToPoint(l_InclusionBoundary[i].x, l_InclusionBoundary[i].y);
}
path.CloseSubpath();
wxGC->StrokePath(path);
wxGC->FillPath( path );
delete wxGC;
ExpandedBoundaries.clear();
polys.clear();
poly.clear();
co.Clear();
}
wxDELETEA( m_bpts );
}
ODPath::Draw( dc, piVP );
}
示例5: DrawGL
void Boundary::DrawGL( PlugIn_ViewPort &piVP )
{
#ifdef ocpnUSE_GL
if ( !m_bVisible ) return;
ODDC dc;
if(m_pODPointList->GetCount() > 2 ) {
if( m_bExclusionBoundary || m_bInclusionBoundary ) {
wxPoint *l_AllPoints;
int l_iAllPointsSizes[2];
wxPoint *l_InclusionBoundary;
int l_iBoundaryPointCount = 0;
m_bpts = new wxPoint[ m_pODPointList->GetCount() ];
wxPoint r;
for(wxODPointListNode *node = m_pODPointList->GetFirst(); node; node = node->GetNext()) {
ODPoint *pOp = node->GetData();
GetCanvasPixLL( &piVP, &r, pOp->m_lat, pOp->m_lon );
m_bpts[ l_iBoundaryPointCount++ ] = r;
}
if( !m_bExclusionBoundary && m_bInclusionBoundary ) {
// surround boundary with hatching if there is more than 10 pixels different between points
int l_imaxpointdiffX = 0;
int l_imaxpointdiffY = 0;
for( size_t i = 1; i < m_pODPointList->GetCount(); i++ ) {
int l_ipointdiffX = abs(m_bpts[0].x - m_bpts[i].x);
int l_ipointdiffY = abs(m_bpts[0].y - m_bpts[i].y);
if(l_ipointdiffX > l_imaxpointdiffX) l_imaxpointdiffX = l_ipointdiffX;
if(l_ipointdiffY > l_imaxpointdiffY) l_imaxpointdiffY = l_ipointdiffY;
}
if(l_imaxpointdiffX < 10 && l_imaxpointdiffY < 10 ) return;
// Use ClipperLib to manage Polygon
// If needed simplify polygons to make shading stay outside
Paths poly(1);
for( int i = 0; i < l_iBoundaryPointCount; i++ ) {
poly[0] << IntPoint( m_bpts[i].x, m_bpts[i].y );
}
Paths simplePolys;
SimplifyPolygons( poly, simplePolys );
ClipperOffset co;
Paths ExpandedBoundaries;
co.AddPaths( simplePolys, jtSquare, etClosedPolygon );
co.Execute( ExpandedBoundaries, m_iInclusionBoundarySize );
int l_iInclusionBoundarySize = ExpandedBoundaries[0].size();
l_InclusionBoundary = new wxPoint[ l_iInclusionBoundarySize + 1 ];
for( int i = 0; i < l_iInclusionBoundarySize; i++ )
{
l_InclusionBoundary[i].x = ExpandedBoundaries[0][i].X;
l_InclusionBoundary[i].y = ExpandedBoundaries[0][i].Y;
}
// need to add first point to end to ensure the polygon is closed
l_InclusionBoundary[ l_iInclusionBoundarySize ].x = ExpandedBoundaries[0][0].X;
l_InclusionBoundary[ l_iInclusionBoundarySize ].y = ExpandedBoundaries[0][0].Y;
// Create one array containing the original polygon joined to the expanded polygon to allow filling
l_iAllPointsSizes[0] = l_iBoundaryPointCount;
l_iAllPointsSizes[1] = l_iInclusionBoundarySize;
l_AllPoints = new wxPoint[ l_iBoundaryPointCount + l_iInclusionBoundarySize + 1 ];
for( int i = 0; i < l_iBoundaryPointCount; i++ ) {
l_AllPoints[i] = m_bpts[ i ];
}
for( int i = 0; i < l_iInclusionBoundarySize; i++ ) {
l_AllPoints[ i + l_iBoundaryPointCount ] = l_InclusionBoundary[i];
}
ExpandedBoundaries.clear();
}
// Each byte represents a single pixel for Alpha. This provides a cross hatch in a 16x16 pixel square
GLubyte slope_cross_hatch[] = {
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00,
0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00,
0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF
};
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture( GL_TEXTURE_2D, textureID );
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, 16, 16, 0, GL_ALPHA, GL_UNSIGNED_BYTE, slope_cross_hatch );
dc.SetTextureSize( 16, 16 );
//.........这里部分代码省略.........
示例6: main
int main(int argc, char** argv)
{
string commandLine;
{
ostringstream ss;
char** last = argv + argc - 1;
copy(argv, last, ostream_iterator<const char *>(ss, " "));
ss << *last;
commandLine = ss.str();
}
if (!opt::db.empty())
opt::metaVars.resize(3);
bool die = false;
for (int c; (c = getopt_long(argc, argv,
shortopts, longopts, NULL)) != -1;) {
istringstream arg(optarg != NULL ? optarg : "");
switch (c) {
case '?': die = true; break;
case 'g': arg >> opt::graphPath; break;
case 'k': arg >> opt::k; break;
case 'r': arg >> opt::repeatContigs; break;
case 'v': opt::verbose++; break;
case OPT_HELP:
cout << USAGE_MESSAGE;
exit(EXIT_SUCCESS);
case OPT_VERSION:
cout << VERSION_MESSAGE;
exit(EXIT_SUCCESS);
case OPT_DB:
arg >> opt::db; break;
case OPT_LIBRARY:
arg >> opt::metaVars[0]; break;
case OPT_STRAIN:
arg >> opt::metaVars[1]; break;
case OPT_SPECIES:
arg >> opt::metaVars[2]; break;
}
if (optarg != NULL && !arg.eof()) {
cerr << PROGRAM ": invalid option: `-"
<< (char)c << optarg << "'\n";
exit(EXIT_FAILURE);
}
}
if (opt::k <= 0) {
cerr << PROGRAM ": missing -k,--kmer option\n";
die = true;
}
if (argc - optind < 2) {
cerr << PROGRAM ": missing arguments\n";
die = true;
} else if (argc - optind > 2) {
cerr << PROGRAM ": too many arguments\n";
die = true;
}
if (die) {
cerr << "Try `" << PROGRAM
<< " --help' for more information.\n";
exit(EXIT_FAILURE);
}
const char *adjPath = argv[optind++];
if (opt::verbose > 0)
cerr << "Reading `" << adjPath << "'..." << endl;
ifstream fin(adjPath);
assert_good(fin, adjPath);
Graph g;
fin >> g;
Vertex::s_offset = g.num_vertices() / 2;
string pathsFile(argv[optind++]);
vector<string> pathIDs;
Paths paths = readPaths(g, pathsFile, pathIDs);
switch (opt::mode) {
case opt::OVERLAP:
// Find overlapping paths, do not assemble.
addPathOverlapEdges(g, paths, pathIDs,
findOverlaps(g, paths));
paths.clear();
if (opt::graphPath.empty())
opt::graphPath = "-";
break;
case opt::ASSEMBLE:
// Assemble overlapping paths.
assembleOverlappingPaths(g, paths, pathIDs);
break;
case opt::TRIM:
// Trim overlapping paths.
trimOverlaps(g, paths);
// Remove paths consisting of a single contig.
for_each_if(paths.begin(), paths.end(),
mem_fun_ref(&ContigPath::clear),
compose1(
//.........这里部分代码省略.........