OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Public Attributes | List of all members
ossimPotraceTool::Path Class Reference

Public Member Functions

 Path ()
 
 ~Path ()
 
void addPotraceCurve (potrace_curve_t &curve, int segment)
 

Public Attributes

std::vector< ossimDptvertices
 
bool closed
 

Detailed Description

Definition at line 42 of file ossimPotraceTool.h.

Constructor & Destructor Documentation

◆ Path()

ossimPotraceTool::Path::Path ( )
inline

Definition at line 45 of file ossimPotraceTool.h.

45 : closed(true) {}

◆ ~Path()

ossimPotraceTool::Path::~Path ( )

Definition at line 525 of file ossimPotraceTool.cpp.

References vertices.

526 {
527  vertices.clear();
528 }
std::vector< ossimDpt > vertices

Member Function Documentation

◆ addPotraceCurve()

void ossimPotraceTool::Path::addPotraceCurve ( potrace_curve_t curve,
int  segment 
)

Definition at line 531 of file ossimPotraceTool.cpp.

References potrace_curve_s::c, POTRACE_CORNER, potrace_curve_s::tag, potrace_dpoint_s::x, ossimDpt::x, x, potrace_dpoint_s::y, ossimDpt::y, and y.

Referenced by ossimPotraceTool::transformLineStrings().

532 {
533  potrace_dpoint_t *c = curve.c[segment];
534  if (curve.tag[segment] == POTRACE_CORNER)
535  {
536  // Just add next connected line segment
537  ossimDpt v1 (c[1].x, c[1].y);
538  ossimDpt v2 (c[2].x, c[2].y);
539  vertices.push_back(v1);
540  vertices.push_back(v2);
541  //cout <<" Added corners v1:"<<v1<<endl;
542  //cout <<" v2:"<<v2<<endl;
543  }
544  else
545  {
546  // Need to convert bezier curve representation to line segments:
547  ossimDpt v0;
548  ossimDpt v1 (c[0].x, c[0].y);
549  ossimDpt v2 (c[1].x, c[1].y);
550  ossimDpt v3 (c[2].x, c[2].y);
551 
552  // Need the first vertex from the previous segment if available:
553  if (segment == 0)
554  v0 = v1;
555  else
556  {
557  c = curve.c[segment-1];
558  v0.x = c[2].x;
559  v0.y = c[2].y;
560  }
561  //cout <<" Processing curve v0:"<<v0<<endl;
562  //cout <<" v1:"<<v1<<endl;
563  //cout <<" v2:"<<v2<<endl;
564  //cout <<" v3:"<<v3<<endl;
565 
566  // Now loop to extract line segments from bezier curve:
567  double step, t, s;
568  ossimDpt vertex;
569  step = 1.0 / 8.0;
570  t = step;
571  for (int i=0; i<8; i++)
572  {
573  s = 1.0 - t;
574  vertex.x = s*s*s*v0.x + 3*(s*s*t)*v1.x + 3*(t*t*s)*v2.x + t*t*t*v3.x;
575  vertex.y = s*s*s*v0.y + 3*(s*s*t)*v1.y + 3*(t*t*s)*v2.y + t*t*t*v3.y;
576  vertices.push_back(vertex);
577  t += step;
578  //cout <<" added vertex:"<<vertex<<endl;
579  }
580  }
581 }
ossim_uint32 x
ossim_uint32 y
double y
Definition: ossimDpt.h:165
#define POTRACE_CORNER
Definition: potracelib.h:73
std::vector< ossimDpt > vertices
double x
Definition: ossimDpt.h:164
potrace_dpoint_t(* c)[3]
Definition: potracelib.h:80

Member Data Documentation

◆ closed

bool ossimPotraceTool::Path::closed

Definition at line 49 of file ossimPotraceTool.h.

Referenced by ossimPotraceTool::transformLineStrings().

◆ vertices

std::vector<ossimDpt> ossimPotraceTool::Path::vertices

Definition at line 48 of file ossimPotraceTool.h.

Referenced by ossimPotraceTool::transformLineStrings(), and ~Path().


The documentation for this class was generated from the following files: