LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lc::operation::Loop Class Reference

The Loop class Allows for looping over a set of entities. More...

#include <entityops.h>

Inheritance diagram for lc::operation::Loop:
Collaboration diagram for lc::operation::Loop:

Public Member Functions

 Loop (const int numTimes)
 
virtual ~Loop ()
 
virtual std::vector
< entity::CADEntity_CSPtr > 
process (const Document_SPtr document, std::vector< entity::CADEntity_CSPtr > entities, std::vector< entity::CADEntity_CSPtr > &workingBuffer, std::vector< entity::CADEntity_CSPtr > &removals, const std::vector< Base_SPtr > operationStack)
 
- Public Member Functions inherited from lc::operation::Base
virtual ~Base ()
 
virtual std::vector
< entity::CADEntity_CSPtr > 
process (const std::shared_ptr< Document >, const std::vector< entity::CADEntity_CSPtr > entities, std::vector< entity::CADEntity_CSPtr > &workingBuffer, std::vector< entity::CADEntity_CSPtr > &removals, const std::vector< Base_SPtr > operationStack)=0
 

Private Attributes

int _numTimes
 

Detailed Description

The Loop class Allows for looping over a set of entities.

Example (lua):

l=Line(Coord(0,0), Coord(10,100));
d=app.currentDocument()
b=Builder(d)
b:append(l)
b:copy(Coord(0,0))
b:rotate(Coord(0,0), math.rad(45))
b:loop(7); – loop 7 times over the copt/rotate operations
b:execute()

Definition at line 50 of file entityops.h.

Constructor & Destructor Documentation

Loop::Loop ( const int  numTimes)

Loop

Definition at line 39 of file entityops.cpp.

39  : Base(), _numTimes(numTimes) {
40 }
Loop::~Loop ( )
virtual

Definition at line 76 of file entityops.cpp.

76  {
77 
78 }

Member Function Documentation

std::vector< entity::CADEntity_CSPtr > Loop::process ( const Document_SPtr  document,
std::vector< entity::CADEntity_CSPtr >  entities,
std::vector< entity::CADEntity_CSPtr > &  workingBuffer,
std::vector< entity::CADEntity_CSPtr > &  removals,
const std::vector< Base_SPtr >  operationStack 
)
virtual

Definition at line 42 of file entityops.cpp.

47  {
48  std::vector<entity::CADEntity_CSPtr> final;
49 
50  // Find the start
51  std::vector<entity::CADEntity_CSPtr> _start;
52 
53  for (auto base : _stack) {
54  //TODO can we get rid of dynamic_cast??
55  const lc::operation::Begin* begin = dynamic_cast<const lc::operation::Begin*>(base.get());
56 
57  if (begin != nullptr) {
58  auto entities = begin->getEntities();
59  _start.insert(_start.end(), entities.begin(), entities.end());
60  }
61  }
62 
63 
64  // run the operation queue
65  std::vector<entity::CADEntity_CSPtr> entitySet2(entitySet);
66 
67  for (int n = 0; n < _numTimes - 1; n++) {
68  for (auto base : _stack) {
69  entitySet2 = base->process(document, entitySet2, _workingBuffer, removals, _stack);
70  }
71  }
72 
73  return entitySet2;
74 }
std::vector< entity::CADEntity_CSPtr > getEntities() const
Definition: entityops.cpp:24
The begin class Allows for setting up the beginning of a loop (NOT YET IMPLEMENTED) ...
Definition: entityops.h:86

Member Data Documentation

int lc::operation::Loop::_numTimes
private

Definition at line 64 of file entityops.h.


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