• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.14
  • kdeedu
  • kig
  • objects
polygon_type.cc
Go to the documentation of this file.
1 // Copyright (C) 2003 Maurizio Paolini <paolini@dmf.unicatt.it>
2 
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #include "polygon_type.h"
19 
20 #include <math.h>
21 
22 #include "bogus_imp.h"
23 #include "line_imp.h"
24 #include "point_imp.h"
25 #include "polygon_imp.h"
26 #include "object_calcer.h"
27 
28 #include "../misc/common.h"
29 
30 #include <klocale.h>
31 #include <cmath>
32 #include <vector>
33 
34 /*
35  * triangle by its vertices
36  */
37 
38 static const char triangle_constructstatement[] = I18N_NOOP( "Construct a triangle with this vertex" );
39 static const char triangle_constructstatement2[] = I18N_NOOP( "Select a point to be a vertex of the new triangle..." );
40 
41 static const struct ArgsParser::spec argsspecTriangleB3P[] =
42 {
43  { PointImp::stype(), triangle_constructstatement, triangle_constructstatement2, true },
44  { PointImp::stype(), triangle_constructstatement, triangle_constructstatement2, true },
45  { PointImp::stype(), triangle_constructstatement, triangle_constructstatement2, true }
46 };
47 
48 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( TriangleB3PType )
49 
50 TriangleB3PType::TriangleB3PType()
51  : ArgsParserObjectType( "TriangleB3P", argsspecTriangleB3P, 3 )
52 {
53 }
54 
55 TriangleB3PType::~TriangleB3PType()
56 {
57 }
58 
59 const TriangleB3PType* TriangleB3PType::instance()
60 {
61  static const TriangleB3PType s;
62  return &s;
63 }
64 
65 ObjectImp* TriangleB3PType::calc( const Args& parents, const KigDocument& ) const
66 {
67  if ( ! margsparser.checkArgs( parents, 1 ) ) return new InvalidImp;
68  std::vector<Coordinate> points;
69 
70  Coordinate centerofmass3 = Coordinate( 0, 0 );
71  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
72  {
73  Coordinate point = static_cast<const PointImp*>( *i )->coordinate();
74  centerofmass3 += point;
75  points.push_back( point );
76  }
77  // return new PolygonImp( 3, points, centerofmass3/3 );
78  return new FilledPolygonImp( points );
79 }
80 
81 const ObjectImpType* TriangleB3PType::resultId() const
82 {
83  return FilledPolygonImp::stype();
84 }
85 
86 bool TriangleB3PType::canMove( const ObjectTypeCalcer& o ) const
87 {
88  return isFreelyTranslatable( o );
89 }
90 
91 bool TriangleB3PType::isFreelyTranslatable( const ObjectTypeCalcer& o ) const
92 {
93  std::vector<ObjectCalcer*> parents = o.parents();
94  return parents[0]->isFreelyTranslatable() &&
95  parents[1]->isFreelyTranslatable() &&
96  parents[2]->isFreelyTranslatable();
97 }
98 
99 void TriangleB3PType::move( ObjectTypeCalcer& o, const Coordinate& to,
100  const KigDocument& d ) const
101 {
102  std::vector<ObjectCalcer*> parents = o.parents();
103  assert( margsparser.checkArgs( parents ) );
104  const Coordinate a = static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
105  const Coordinate b = static_cast<const PointImp*>( parents[1]->imp() )->coordinate();
106  const Coordinate c = static_cast<const PointImp*>( parents[2]->imp() )->coordinate();
107  if ( parents[0]->canMove() )
108  parents[0]->move( to, d );
109  if ( parents[1]->canMove() )
110  parents[1]->move( to + b - a, d );
111  if ( parents[2]->canMove() )
112  parents[2]->move( to + c - a, d );
113 }
114 
115 const Coordinate TriangleB3PType::moveReferencePoint( const ObjectTypeCalcer& o ) const
116 {
117  std::vector<ObjectCalcer*> parents = o.parents();
118  assert( margsparser.checkArgs( parents ) );
119  return static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
120 }
121 
122 std::vector<ObjectCalcer*> TriangleB3PType::movableParents( const ObjectTypeCalcer& ourobj ) const
123 {
124  std::vector<ObjectCalcer*> parents = ourobj.parents();
125  std::set<ObjectCalcer*> ret;
126  std::vector<ObjectCalcer*> tmp = parents[0]->movableParents();
127  ret.insert( tmp.begin(), tmp.end() );
128  tmp = parents[1]->movableParents();
129  ret.insert( tmp.begin(), tmp.end() );
130  tmp = parents[2]->movableParents();
131  ret.insert( tmp.begin(), tmp.end() );
132  ret.insert( parents.begin(), parents.end() );
133  return std::vector<ObjectCalcer*>( ret.begin(), ret.end() );
134 }
135 
136 /*
137  * generic polygon
138  */
139 
140 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( PolygonBNPType )
141 
142 PolygonBNPType::PolygonBNPType()
143  : ObjectType( "PolygonBNP" )
144 {
145 }
146 
147 PolygonBNPType::~PolygonBNPType()
148 {
149 }
150 
151 const PolygonBNPType* PolygonBNPType::instance()
152 {
153  static const PolygonBNPType s;
154  return &s;
155 }
156 
157 ObjectImp* PolygonBNPType::calc( const Args& parents, const KigDocument& ) const
158 {
159  uint count = parents.size();
160  assert (count >= 3); /* non sono ammessi poligoni con meno di tre lati */
161 // if ( parents[0] != parents[count] ) return new InvalidImp;
162  std::vector<Coordinate> points;
163 
164  uint npoints = 0;
165  Coordinate centerofmassn = Coordinate( 0, 0 );
166 
167  for ( uint i = 0; i < count; ++i )
168  {
169  npoints++;
170  if ( ! parents[i]->inherits( PointImp::stype() ) ) return new InvalidImp;
171  Coordinate point = static_cast<const PointImp*>( parents[i] )->coordinate();
172  centerofmassn += point;
173  points.push_back( point );
174  }
175  //return new PolygonImp( npoints, points, centerofmassn/npoints );
176  return new FilledPolygonImp( points );
177 }
178 
179 const ObjectImpType* PolygonBNPType::resultId() const
180 {
181  return FilledPolygonImp::stype();
182 }
183 
184 const ObjectImpType* PolygonBNPType::impRequirement( const ObjectImp*, const Args& ) const
185 {
186  return PointImp::stype();
187 }
188 
189 bool PolygonBNPType::isDefinedOnOrThrough( const ObjectImp*, const Args& ) const
190 {
191  return false; /* should be true? */
192 }
193 
194 std::vector<ObjectCalcer*> PolygonBNPType::sortArgs( const std::vector<ObjectCalcer*>& args ) const
195 {
196  return args; /* should already be in correct order */
197 }
198 
199 Args PolygonBNPType::sortArgs( const Args& args ) const
200 {
201  return args;
202 }
203 
204 bool PolygonBNPType::canMove( const ObjectTypeCalcer& o ) const
205 {
206  return isFreelyTranslatable( o );
207 }
208 
209 bool PolygonBNPType::isFreelyTranslatable( const ObjectTypeCalcer& o ) const
210 {
211  std::vector<ObjectCalcer*> parents = o.parents();
212  for ( uint i = 0; i < parents.size(); ++i )
213  {
214  if ( !parents[i]->isFreelyTranslatable() ) return false;
215  }
216  return true;
217 }
218 
219 void PolygonBNPType::move( ObjectTypeCalcer& o, const Coordinate& to,
220  const KigDocument& d ) const
221 {
222  std::vector<ObjectCalcer*> parents = o.parents();
223  const Coordinate ref = static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
224  for ( uint i = 0; i < parents.size(); ++i )
225  {
226  const Coordinate a = static_cast<const PointImp*>( parents[i]->imp() )->coordinate();
227  parents[i]->move( to + a - ref, d );
228  }
229 }
230 
231 const Coordinate PolygonBNPType::moveReferencePoint( const ObjectTypeCalcer& o
232 ) const
233 {
234  std::vector<ObjectCalcer*> parents = o.parents();
235  return static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
236 }
237 
238 std::vector<ObjectCalcer*> PolygonBNPType::movableParents( const ObjectTypeCalcer& ourobj ) const
239 {
240  std::vector<ObjectCalcer*> parents = ourobj.parents();
241  std::set<ObjectCalcer*> ret;
242  for ( uint i = 0; i < parents.size(); ++i )
243  {
244  std::vector<ObjectCalcer*> tmp = parents[i]->movableParents();
245  ret.insert( tmp.begin(), tmp.end() );
246  }
247  ret.insert( parents.begin(), parents.end() );
248  return std::vector<ObjectCalcer*>( ret.begin(), ret.end() );
249 }
250 
251 /*
252  * Added by Petr Gajdos <pgajdos@suse.cz>
253  * opened polygon
254  */
255 
256 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( OpenPolygonType )
257 
258 OpenPolygonType::OpenPolygonType()
259  : ObjectType( "OpenPolygon" )
260 {
261 }
262 
263 OpenPolygonType::~OpenPolygonType()
264 {
265 }
266 
267 const OpenPolygonType* OpenPolygonType::instance()
268 {
269  static const OpenPolygonType s;
270  return &s;
271 }
272 
273 ObjectImp* OpenPolygonType::calc( const Args& parents, const KigDocument& ) const
274 {
275  uint count = parents.size();
276  assert (count >= 3);
277  std::vector<Coordinate> points;
278 
279  uint npoints = 0;
280  for ( uint i = 0; i < count; ++i )
281  {
282  npoints++;
283  if ( ! parents[i]->inherits( PointImp::stype() ) ) return new InvalidImp;
284  Coordinate point = static_cast<const PointImp*>( parents[i] )->coordinate();
285  points.push_back( point );
286  }
287  return new OpenPolygonalImp( points ); // minside = false, mopen = true
288 }
289 
290 const ObjectImpType* OpenPolygonType::resultId() const
291 {
292  return OpenPolygonalImp::stype();
293 }
294 
295 const ObjectImpType* OpenPolygonType::impRequirement( const ObjectImp*, const Args& ) const
296 {
297  return PointImp::stype();
298 }
299 
300 bool OpenPolygonType::isDefinedOnOrThrough( const ObjectImp*, const Args& ) const
301 {
302  return true;
303 }
304 
305 std::vector<ObjectCalcer*> OpenPolygonType::sortArgs( const std::vector<ObjectCalcer*>& args ) const
306 {
307  return args; /* should already be in correct order */
308 }
309 
310 Args OpenPolygonType::sortArgs( const Args& args ) const
311 {
312  return args;
313 }
314 
315 bool OpenPolygonType::canMove( const ObjectTypeCalcer& o ) const
316 {
317  return isFreelyTranslatable( o );
318 }
319 
320 bool OpenPolygonType::isFreelyTranslatable( const ObjectTypeCalcer& o ) const
321 {
322  std::vector<ObjectCalcer*> parents = o.parents();
323  for ( uint i = 0; i < parents.size(); ++i )
324  {
325  if ( !parents[i]->isFreelyTranslatable() ) return false;
326  }
327  return true;
328 }
329 
330 void OpenPolygonType::move( ObjectTypeCalcer& o, const Coordinate& to,
331  const KigDocument& d ) const
332 {
333  std::vector<ObjectCalcer*> parents = o.parents();
334  const Coordinate ref = static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
335  for ( uint i = 0; i < parents.size(); ++i )
336  {
337  const Coordinate a = static_cast<const PointImp*>( parents[i]->imp() )->coordinate();
338  parents[i]->move( to + a - ref, d );
339  }
340 }
341 
342 const Coordinate OpenPolygonType::moveReferencePoint( const ObjectTypeCalcer& o
343 ) const
344 {
345  std::vector<ObjectCalcer*> parents = o.parents();
346  return static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
347 }
348 
349 std::vector<ObjectCalcer*> OpenPolygonType::movableParents( const ObjectTypeCalcer& ourobj ) const
350 {
351  std::vector<ObjectCalcer*> parents = ourobj.parents();
352  std::set<ObjectCalcer*> ret;
353  for ( uint i = 0; i < parents.size(); ++i )
354  {
355  std::vector<ObjectCalcer*> tmp = parents[i]->movableParents();
356  ret.insert( tmp.begin(), tmp.end() );
357  }
358  ret.insert( parents.begin(), parents.end() );
359  return std::vector<ObjectCalcer*>( ret.begin(), ret.end() );
360 }
361 
362 
363 /*
364  * regular polygon by center and vertex
365  */
366 
367 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( PolygonBCVType )
368 
369 PolygonBCVType::PolygonBCVType()
370  : ObjectType( "PoligonBCV" )
371 {
372 }
373 
374 PolygonBCVType::~PolygonBCVType()
375 {
376 }
377 
378 const PolygonBCVType* PolygonBCVType::instance()
379 {
380  static const PolygonBCVType s;
381  return &s;
382 }
383 
384 ObjectImp* PolygonBCVType::calc( const Args& parents, const KigDocument& ) const
385 {
386  if ( parents.size() < 3 || parents.size() > 4 ) return new InvalidImp;
387 
388  if ( ( ! parents[0]->inherits( PointImp::stype() ) ) ||
389  ( ! parents[1]->inherits( PointImp::stype() ) ) ||
390  ( ! parents[2]->inherits( IntImp::stype() ) ) )
391  return new InvalidImp;
392 
393  const Coordinate center =
394  static_cast<const PointImp*>( parents[0] )->coordinate();
395  const Coordinate vertex =
396  static_cast<const PointImp*>( parents[1] )->coordinate();
397  const int sides =
398  static_cast<const IntImp*>( parents[2] )->data();
399  int twist = 1;
400  if ( parents.size() == 4 )
401  {
402  if ( ! parents[3]->inherits( IntImp::stype() ) ) return new InvalidImp;
403  twist = static_cast<const IntImp*>( parents[3] )->data();
404  }
405  std::vector<Coordinate> vertexes;
406 
407  double dx = vertex.x - center.x;
408  double dy = vertex.y - center.y;
409 
410  for ( int i = 1; i <= sides; i++ )
411  {
412  double alfa = 2*twist*M_PI/sides;
413  double theta1 = alfa*i - alfa;
414  double ctheta1 = cos(theta1);
415  double stheta1 = sin(theta1);
416 
417  Coordinate v1 = center + Coordinate( ctheta1*dx - stheta1*dy,
418  stheta1*dx + ctheta1*dy );
419  vertexes.push_back( v1 );
420  }
421  //return new PolygonImp( uint (sides), vertexes, center );
422  return new FilledPolygonImp( vertexes );
423 }
424 
425 const ObjectImpType* PolygonBCVType::resultId() const
426 {
427  return SegmentImp::stype();
428 }
429 
430 const ObjectImpType* PolygonBCVType::impRequirement( const ObjectImp* obj, const Args& ) const
431 {
432  if ( obj->inherits( PointImp::stype() ) )
433  return PointImp::stype();
434 
435  if ( obj->inherits( IntImp::stype() ) )
436  return IntImp::stype();
437 
438  return 0;
439 }
440 
441 bool PolygonBCVType::isDefinedOnOrThrough( const ObjectImp*, const Args& ) const
442 {
443  return false; /* should be true? */
444 }
445 
446 std::vector<ObjectCalcer*> PolygonBCVType::sortArgs( const std::vector<ObjectCalcer*>& args ) const
447 {
448  return args; /* should already be in correct order */
449 }
450 
451 Args PolygonBCVType::sortArgs( const Args& args ) const
452 {
453  return args;
454 }
455 
456 bool PolygonBCVType::canMove( const ObjectTypeCalcer& o ) const
457 {
458  return isFreelyTranslatable( o );
459 }
460 
461 bool PolygonBCVType::isFreelyTranslatable( const ObjectTypeCalcer& o ) const
462 {
463  std::vector<ObjectCalcer*> parents = o.parents();
464  return parents[0]->isFreelyTranslatable() &&
465  parents[1]->isFreelyTranslatable();
466 }
467 
468 void PolygonBCVType::move( ObjectTypeCalcer& o, const Coordinate& to,
469  const KigDocument& d ) const
470 {
471  std::vector<ObjectCalcer*> parents = o.parents();
472  // assert( margsparser.checkArgs( parents ) );
473  if ( ! parents[0]->imp()->inherits( PointImp::stype() ) ||
474  ! parents[1]->imp()->inherits( PointImp::stype() ) ) return;
475 
476  const Coordinate a = static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
477  const Coordinate b = static_cast<const PointImp*>( parents[1]->imp() )->coordinate();
478  parents[0]->move( to, d );
479  parents[1]->move( to + b - a, d );
480 }
481 
482 const Coordinate PolygonBCVType::moveReferencePoint( const ObjectTypeCalcer& o) const
483 {
484  std::vector<ObjectCalcer*> parents = o.parents();
485  // assert( margsparser.checkArgs( parents ) );
486  if ( ! parents[0]->imp()->inherits( PointImp::stype() ) ) return Coordinate::invalidCoord();
487 
488  return static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
489 }
490 
491 std::vector<ObjectCalcer*> PolygonBCVType::movableParents( const ObjectTypeCalcer& ourobj ) const
492 {
493  std::vector<ObjectCalcer*> parents = ourobj.parents();
494  std::set<ObjectCalcer*> ret;
495  std::vector<ObjectCalcer*> tmp = parents[0]->movableParents();
496  ret.insert( tmp.begin(), tmp.end() );
497  tmp = parents[1]->movableParents();
498  ret.insert( tmp.begin(), tmp.end() );
499  ret.insert( &parents[0], &parents[1] );
500  return std::vector<ObjectCalcer*>( ret.begin(), ret.end() );
501 }
502 
503 /* polygon-line intersection */
504 
505 static const ArgsParser::spec argsspecPolygonLineIntersection[] =
506 {
507  { FilledPolygonImp::stype(), I18N_NOOP( "Intersect this polygon with a line" ),
508  I18N_NOOP( "Select the polygon of which you want the intersection with a line..." ), false },
509  { AbstractLineImp::stype(),
510  I18N_NOOP( "Intersect this line with a polygon" ),
511  I18N_NOOP( "Select the line of which you want the intersection with a polygon..." ), false }
512 };
513 
514 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( PolygonLineIntersectionType )
515 
516 PolygonLineIntersectionType::PolygonLineIntersectionType()
517  : ArgsParserObjectType( "PolygonLineIntersection", argsspecPolygonLineIntersection, 2 )
518 {
519 }
520 
521 PolygonLineIntersectionType::PolygonLineIntersectionType( const char fulltypename[],
522  const struct ArgsParser::spec argsspec[],
523  int n )
524  : ArgsParserObjectType( fulltypename, argsspec, n )
525 {
526 }
527 
528 PolygonLineIntersectionType::~PolygonLineIntersectionType()
529 {
530 }
531 
532 const PolygonLineIntersectionType* PolygonLineIntersectionType::instance()
533 {
534  static const PolygonLineIntersectionType t;
535  return &t;
536 }
537 
538 const ObjectImpType* PolygonLineIntersectionType::resultId() const
539 {
540  return SegmentImp::stype();
541 }
542 
543 /*
544  * Intersection of a polygon and a line/ray/segment.
545  *
546  * geometrically speaking the result is always a collection of
547  * collinear nonintersecting open segments (at most one if the
548  * polygon is convex). Since we don't know in advance how many
549  * segments will result, the obvious choice is to return an
550  * InvalidImp in cases when the result is *not* a single segment
551  *
552  * computing the two ends of this segment is more tricky then one
553  * expects especially when intersecting segments/rays.
554  *
555  * particularly "difficult" situations are those where we intersect
556  * a segment/ray with an/the endpoint coinciding with a vertex of
557  * the polygon, especially if that vertex is a "reentrant" (concave)
558  * vertex of the polygon.
559  */
560 
561 ObjectImp* PolygonLineIntersectionType::calc( const Args& parents, const KigDocument& ) const
562 {
563  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
564 
565  const AbstractPolygonImp* polygon = static_cast<const AbstractPolygonImp*>( parents[0] );
566  const std::vector<Coordinate> ppoints = polygon->points();
567  const LineData line = static_cast<const AbstractLineImp*>( parents[1] )->data();
568  double t1, t2;
569  int side = 0;
570  uint numintersections;
571  std::vector<Coordinate>::const_iterator intersectionside;
572 
573  // since we use the same constructor as for ConicLine, we get the values -1 and +1
574  if ( parents.size() >= 3 ) side = static_cast<const IntImp*>( parents[2] )->data();
575  bool boundleft = false;
576  bool boundright = false;
577  if ( parents[1]->inherits( SegmentImp::stype() ) )
578  {
579  boundleft = boundright = true;
580  }
581  if ( parents[1]->inherits( RayImp::stype() ) )
582  {
583  boundleft = true;
584  }
585 
586  bool openpolygon = false;
587  bool inside = false;
588  if ( parents[0]->inherits( OpenPolygonalImp::stype() ) ) openpolygon = true;
589  if ( parents[0]->inherits( FilledPolygonImp::stype() ) ) inside = true;
590 
591  numintersections = polygonlineintersection( ppoints, line.a, line.b,
592  boundleft, boundright, inside, openpolygon, t1, t2, intersectionside );
593 
594  bool filledpolygon = false;
595  if ( parents[0]->inherits( FilledPolygonImp::stype() ) ) filledpolygon = true;
596 
597  if ( ! filledpolygon )
598  {
599  if ( side == -1 && numintersections >= 1) return new PointImp( line.a + t1*(line.b - line.a) );
600  if ( side == 1 && numintersections >= 2) return new PointImp( line.a + t2*(line.b - line.a) );
601  return new InvalidImp;
602  }
603 
604  if (numintersections > 2) return new InvalidImp;
605 
606  switch (numintersections)
607  {
608  case 1: /* just for completeness: this should never happen */
609  return new PointImp( line.a + t1*(line.b - line.a) );
610  break;
611  case 2:
612  return new SegmentImp( line.a + t1*(line.b - line.a),
613  line.a + t2*(line.b - line.a) );
614  break;
615  }
616  return new InvalidImp;
617 }
618 
619 /*
620  * polygonal curve--line intersection, this has an extra parameter
621  * indicating which intersection point we want
622  */
623 
624 static const ArgsParser::spec argsspecOPolygonalLineIntersection[] =
625 {
626  { OpenPolygonalImp::stype(), I18N_NOOP( "Intersect this polygonal curve with a line" ),
627  I18N_NOOP( "Select the polygonal curve of which you want the intersection with a line..." ), false },
628  { AbstractLineImp::stype(),
629  I18N_NOOP( "Intersect this line with a polygonal curve" ),
630  I18N_NOOP( "Select the line of which you want the intersection with a polygonal curve..." ), false },
631  { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
632 };
633 
634 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( OPolygonalLineIntersectionType )
635 
636 OPolygonalLineIntersectionType::OPolygonalLineIntersectionType()
637  : PolygonLineIntersectionType( "OPolygonalLineIntersection", argsspecOPolygonalLineIntersection, 3 )
638 {
639 }
640 
641 OPolygonalLineIntersectionType::~OPolygonalLineIntersectionType()
642 {
643 }
644 
645 const OPolygonalLineIntersectionType* OPolygonalLineIntersectionType::instance()
646 {
647  static const OPolygonalLineIntersectionType t;
648  return &t;
649 }
650 
651 const ObjectImpType* OPolygonalLineIntersectionType::resultId() const
652 {
653  return PointImp::stype();
654 }
655 
656 static const ArgsParser::spec argsspecCPolygonalLineIntersection[] =
657 {
658  { ClosedPolygonalImp::stype(), I18N_NOOP( "Intersect this polygonal curve with a line" ),
659  I18N_NOOP( "Select the polygonal curve of which you want the intersection with a line..." ), false },
660  { AbstractLineImp::stype(),
661  I18N_NOOP( "Intersect this line with a polygonal curve" ),
662  I18N_NOOP( "Select the line of which you want the intersection with a polygonal curve..." ), false },
663  { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
664 };
665 
666 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CPolygonalLineIntersectionType )
667 
668 CPolygonalLineIntersectionType::CPolygonalLineIntersectionType()
669  : PolygonLineIntersectionType( "CPolygonalLineIntersection", argsspecCPolygonalLineIntersection, 3 )
670 {
671 }
672 
673 CPolygonalLineIntersectionType::~CPolygonalLineIntersectionType()
674 {
675 }
676 
677 const CPolygonalLineIntersectionType* CPolygonalLineIntersectionType::instance()
678 {
679  static const CPolygonalLineIntersectionType t;
680  return &t;
681 }
682 
683 const ObjectImpType* CPolygonalLineIntersectionType::resultId() const
684 {
685  return PointImp::stype();
686 }
687 
688 /*
689  * this function computes the intersection of a polygon (given its
690  * list of vertices) with a line/ray/segment described by two points;
691  * the booleans boundleft, boundright discriminates between the
692  * line/ray/segment case.
693  * the integer returned is the number of "endpoints" in the computed
694  * intersection, 0 means no intersection, 1 should never be returned
695  * 2 means that the intersection is just a single segment,
696  * 3 or more means that the intersection consists of more than one segment,
697  * in which case only the intersection with smallest values of the parameter
698  * ent is returned.
699  * t1 and t2 are the two values of the parameter that produce
700  * the two endpoints (in case the return value is >= 2) of the
701  * computed intersection segment: a + t*(b-a).
702  * The "intersectionside" parameter (needed for the computation of
703  * the polygon-polygon intersection) is a pointer to the vertex of the
704  * polygon preceding the second intersection (t2).
705  *
706  * this function is rather involved, mainly because of the special
707  * case when one (or both) the segment endpoints is also one of the
708  * polygon vertices
709  */
710 
711 int
712 polygonlineintersection( const std::vector<Coordinate>& ppoints,
713  const Coordinate a, const Coordinate b,
714  bool boundleft, bool boundright, bool inside,
715  bool openpolygon, double& t1, double& t2,
716  std::vector<Coordinate>::const_iterator& intersectionside )
717 {
718  double intersections[2] = {0.0, 0.0};
719 // uint whichintersection = 0;
720  std::vector<Coordinate>::const_iterator i;
721  std::vector<Coordinate>::const_iterator intersectionsides[2];
722  uint numintersections = 0;
723 
724  double abx = b.x - a.x;
725  double aby = b.y - a.y;
726 
727  bool leftendinside = false;
728  bool rightendinside = false;
729  Coordinate prevpoint = ppoints.back() - a;
730  if ( openpolygon ) prevpoint = ppoints.front() - a;
731  bool prevpointbelow = ( abx*prevpoint.y <= aby*prevpoint.x );
732  for ( i = ppoints.begin(); i != ppoints.end(); ++i )
733  {
734  if ( openpolygon && i == ppoints.begin() ) continue;
735  Coordinate point = *i - a;
736  bool pointbelow = ( abx*point.y <= aby*point.x );
737  if ( pointbelow != prevpointbelow )
738  {
739  /* found an intersection with the support line
740  * compute the value of the parameter...
741  */
742  double dcx = point.x - prevpoint.x;
743  double dcy = point.y - prevpoint.y;
744  double num = point.x*dcy - point.y*dcx;
745  double den = abx*dcy - aby*dcx;
746  if ( std::fabs( den ) <= 1.e-6*std::fabs( num ) ) continue; //parallel
747  double t = num/den;
748  if ( boundleft && t <= 0 )
749  {
750  leftendinside = !leftendinside;
751  }
752  else if ( boundright && t >= 1 )
753  {
754  rightendinside = !rightendinside;
755  }
756  else
757  {
758  numintersections++;
759  if ( t < intersections[1] || numintersections <= 2 )
760  {
761  intersections[1] = t;
762  intersectionsides[1] = i;
763  }
764  if ( t < intersections[0] || numintersections <= 1 )
765  {
766  intersections[1] = intersections[0];
767  intersections[0] = t;
768  intersectionsides[1] = intersectionsides[0];
769  intersectionsides[0] = i;
770  }
771  }
772  }
773  prevpoint = point;
774  prevpointbelow = pointbelow;
775  }
776 
777  if ( inside )
778  {
779  if ( leftendinside )
780  {
781  numintersections++;
782  intersections[1] = intersections[0];
783  intersectionsides[1] = intersectionsides[0];
784  intersections[0] = 0.0;
785  intersectionsides[0] = ppoints.end();
786  }
787  if ( rightendinside )
788  {
789  numintersections++;
790  intersections[1] = 1.0;
791  intersectionsides[1] = ppoints.end();
792  if ( numintersections < 2 )
793  {
794  intersections[0] = 1.0;
795  intersectionsides[1] = ppoints.end();
796  }
797  }
798  }
799 
800  if (numintersections>= 1)
801  {
802  t1 = intersections[0];
803  intersectionside = intersectionsides[0];
804  }
805  if (numintersections >= 2)
806  {
807  t2 = intersections[1];
808  intersectionside = intersectionsides[1];
809  }
810  if ( intersectionside == ppoints.begin() ) intersectionside = ppoints.end();
811  intersectionside--;
812  return numintersections;
813 }
814 
815 int
816 polygonlineintersection( const std::vector<Coordinate>& ppoints,
817  const Coordinate a, const Coordinate b,
818  double& t1, double& t2,
819  std::vector<Coordinate>::const_iterator& intersectionside )
820 {
821  return polygonlineintersection ( ppoints, a, b, true, true, true, false, t1, t2, intersectionside );
822 }
823 
824 /* polygon-polygon intersection */
825 
826 static const ArgsParser::spec argsspecPolygonPolygonIntersection[] =
827 {
828  { FilledPolygonImp::stype(), I18N_NOOP( "Intersect this polygon with another polygon" ),
829  I18N_NOOP( "Select the polygon of which you want the intersection with another polygon..." ), false },
830  { FilledPolygonImp::stype(), I18N_NOOP( "Intersect with this polygon" ),
831  I18N_NOOP( "Select the second polygon for the intersection..." ), false }
832 };
833 
834 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( PolygonPolygonIntersectionType )
835 
836 PolygonPolygonIntersectionType::PolygonPolygonIntersectionType()
837  : ArgsParserObjectType( "PolygonPolygonIntersection", argsspecPolygonPolygonIntersection, 2 )
838 {
839 }
840 
841 PolygonPolygonIntersectionType::~PolygonPolygonIntersectionType()
842 {
843 }
844 
845 const PolygonPolygonIntersectionType* PolygonPolygonIntersectionType::instance()
846 {
847  static const PolygonPolygonIntersectionType t;
848  return &t;
849 }
850 
851 ObjectImp* PolygonPolygonIntersectionType::calc( const Args& parents, const KigDocument& ) const
852 {
853  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
854 
855  const FilledPolygonImp* polygon1 = static_cast<const FilledPolygonImp*>( parents[0] );
856  const std::vector<Coordinate> ppoints1 = polygon1->points();
857  const FilledPolygonImp* polygon2 = static_cast<const FilledPolygonImp*>( parents[1] );
858  const std::vector<Coordinate> ppoints2 = polygon2->points();
859  std::vector<Coordinate> ppointsint;
860  double t1, t2;
861  uint numintersections;
862  std::vector<Coordinate>::const_iterator ipoint, iprevpoint, iprevprevpoint,
863  intersectionside, istartpoint;
864  Coordinate point;
865  const std::vector<Coordinate> *ppointsa, *ppointsb, *ppointsc, *ppointsstart;
866  ppointsa = &ppoints1;
867  ppointsb = &ppoints2;
868  int direction = 1;
869 
870  if ( polygon1->isTwisted() || polygon2->isTwisted() ) return new InvalidImp;
871 
872  bool intersect = false;
873 
874  for (int k = 0; k <2; k++)
875  {
876  iprevpoint = ppointsa->end();
877  --iprevpoint;
878  for (ipoint = ppointsa->begin(); ipoint != ppointsa->end(); ++ipoint)
879  {
880  numintersections = polygonlineintersection( *ppointsb,
881  *iprevpoint, *ipoint, t1, t2, intersectionside);
882  if (numintersections >= 2)
883  {
884  intersect = true;
885  break;
886  }
887  iprevpoint = ipoint;
888  }
889  if (intersect) break;
890  ppointsa = &ppoints2;
891  ppointsb = &ppoints1;
892  }
893 
894  if ( ! intersect ) return new InvalidImp;
895  ppointsstart = ppointsa;
896  istartpoint = ipoint;
897  point = *iprevpoint + t1*(*ipoint-*iprevpoint);
898  ppointsint.push_back( point );
899  point = *iprevpoint + t2*(*ipoint-*iprevpoint);
900  ppointsint.push_back( point );
901 
902  do
903  {
904  if ( t2 == 1.0 )
905  {
906  /*
907  * in this case I will continue cicling along the current polygon
908  */
909  iprevprevpoint = iprevpoint; /* we need this in the special case */
910  iprevpoint = ipoint;
911  if ( direction < 0 && ipoint == ppointsa->begin() ) ipoint = ppointsa->end();
912  ipoint += direction;
913  if ( ipoint == ppointsa->end() ) ipoint = ppointsa->begin();
914  numintersections = polygonlineintersection( *ppointsb,
915  *iprevpoint, *ipoint, t1, t2, intersectionside);
916  if ( numintersections < 2 )
917  {
918  /*
919  * this is a special case. We are here e.g. if the two polygons have a
920  * common vertex
921  * We treat this case in a tricky way :-(
922  * Still, if the two polygons have some common vertices the
923  * result is sometimes unpredictable :-(
924  */
925  point = 1e-10*(*iprevprevpoint) + (1 - 1e-10)*(*iprevpoint);
926  numintersections = polygonlineintersection( *ppointsb,
927  point, *ipoint, t1, t2, intersectionside);
928  } else
929  {
930  if ( t1 != 0.0 ) return new InvalidImp; /* can this happen? */
931  point = *iprevpoint + t2*(*ipoint-*iprevpoint);
932  ppointsint.push_back( point );
933  }
934  } else
935  {
936  /*
937  * in this case I must cicle along the other polygon
938  */
939  ppointsc = ppointsa;
940  ppointsa = ppointsb;
941  ppointsb = ppointsc;
942  ipoint = iprevpoint = intersectionside;
943  ipoint++;
944  if ( ipoint == ppointsa->end() ) ipoint = ppointsa->begin();
945  point = ppointsint.back();
946  direction = 1;
947  numintersections = polygonlineintersection( *ppointsb,
948  point, *ipoint, t1, t2, intersectionside);
949  if ( numintersections < 2 || t2 < 1e-12)
950  {
951  direction = -1;
952  ipoint = iprevpoint;
953  numintersections = polygonlineintersection( *ppointsb,
954  point, *ipoint, t1, t2, intersectionside);
955  if (numintersections < 2) return new InvalidImp;
956  }
957  point = point + t2*(*ipoint-point);
958  ppointsint.push_back( point );
959  }
960  } while ( ( ppointsstart != ppointsa || istartpoint != ipoint ) && ppointsint.size() < 1000 );
961 
962  if (ppointsint.size() < 2) return new InvalidImp; /* should never happen */
963  ppointsint.pop_back();
964  ppointsint.pop_back();
965  return new FilledPolygonImp (ppointsint);
966 }
967 
968 const ObjectImpType* PolygonPolygonIntersectionType::resultId() const
969 {
970  return FilledPolygonImp::stype();
971 }
972 
973 /* polygon vertices */
974 
975 static const ArgsParser::spec argsspecPolygonVertex[] =
976 {
977  { FilledPolygonImp::stype(), I18N_NOOP( "Construct the vertices of this polygon" ),
978  I18N_NOOP( "Select the polygon of which you want to construct the vertices..." ), true },
979  { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
980 };
981 
982 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( PolygonVertexType )
983 
984 PolygonVertexType::PolygonVertexType()
985  : ArgsParserObjectType( "PolygonVertex", argsspecPolygonVertex, 2 )
986 {
987 }
988 
989 PolygonVertexType::~PolygonVertexType()
990 {
991 }
992 
993 const PolygonVertexType* PolygonVertexType::instance()
994 {
995  static const PolygonVertexType t;
996  return &t;
997 }
998 
999 ObjectImp* PolygonVertexType::calc( const Args& parents, const KigDocument& ) const
1000 {
1001  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
1002 
1003  const std::vector<Coordinate> ppoints = static_cast<const FilledPolygonImp*>( parents[0] )->points();
1004  const uint i = static_cast<const IntImp*>( parents[1] )->data();
1005 
1006  if ( i >= ppoints.size() ) return new InvalidImp;
1007 
1008  return new PointImp( ppoints[i] );
1009 }
1010 
1011 const ObjectImpType* PolygonVertexType::resultId() const
1012 {
1013  return PointImp::stype();
1014 }
1015 
1016 /* polygon sides */
1017 
1018 static const ArgsParser::spec argsspecPolygonSide[] =
1019 {
1020  { FilledPolygonImp::stype(), I18N_NOOP( "Construct the sides of this polygon" ),
1021  I18N_NOOP( "Select the polygon of which you want to construct the sides..." ), false },
1022  { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
1023 };
1024 
1025 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( PolygonSideType )
1026 
1027 PolygonSideType::PolygonSideType()
1028  : ArgsParserObjectType( "PolygonSide", argsspecPolygonSide, 2 )
1029 {
1030 }
1031 
1032 PolygonSideType::~PolygonSideType()
1033 {
1034 }
1035 
1036 const PolygonSideType* PolygonSideType::instance()
1037 {
1038  static const PolygonSideType t;
1039  return &t;
1040 }
1041 
1042 ObjectImp* PolygonSideType::calc( const Args& parents, const KigDocument& ) const
1043 {
1044  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
1045 
1046  const std::vector<Coordinate> ppoints = static_cast<const FilledPolygonImp*>( parents[0] )->points();
1047  const uint i = static_cast<const IntImp*>( parents[1] )->data();
1048 
1049  if ( i >= ppoints.size() ) return new InvalidImp;
1050 
1051  uint nexti = i + 1;
1052  if ( nexti >= ppoints.size() ) nexti = 0;
1053 
1054  return new SegmentImp( ppoints[i], ppoints[nexti] );
1055 }
1056 
1057 const ObjectImpType* PolygonSideType::resultId() const
1058 {
1059  return SegmentImp::stype();
1060 }
1061 
1062 /* convex hull of a polygon */
1063 
1064 static const ArgsParser::spec argsspecConvexHull[] =
1065 {
1066  { AbstractPolygonImp::stype(), I18N_NOOP( "Construct the convex hull of this polygon" ),
1067  I18N_NOOP( "Select the polygon of which you want to construct the convex hull..." ), false }
1068 };
1069 
1070 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConvexHullType )
1071 
1072 ConvexHullType::ConvexHullType()
1073  : ArgsParserObjectType( "ConvexHull", argsspecConvexHull, 1 )
1074 {
1075 }
1076 
1077 ConvexHullType::~ConvexHullType()
1078 {
1079 }
1080 
1081 const ConvexHullType* ConvexHullType::instance()
1082 {
1083  static const ConvexHullType t;
1084  return &t;
1085 }
1086 
1087 ObjectImp* ConvexHullType::calc( const Args& parents, const KigDocument& ) const
1088 {
1089  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
1090 
1091  const std::vector<Coordinate> ppoints = static_cast<const AbstractPolygonImp*>( parents[0] )->points();
1092 
1093  if ( ppoints.size() < 3 ) return new InvalidImp;
1094 
1095  std::vector<Coordinate> hull = computeConvexHull( ppoints );
1096  if ( hull.size() < 3 ) return new InvalidImp;
1097  return new FilledPolygonImp( hull );
1098 }
1099 
1100 const ObjectImpType* ConvexHullType::resultId() const
1101 {
1102  return FilledPolygonImp::stype();
1103 }
ConvexHullType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:1100
CPolygonalLineIntersectionType::instance
static const CPolygonalLineIntersectionType * instance()
Definition: polygon_type.cc:677
PolygonBNPType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:157
PolygonLineIntersectionType::~PolygonLineIntersectionType
~PolygonLineIntersectionType()
Definition: polygon_type.cc:528
argsspecConvexHull
static const ArgsParser::spec argsspecConvexHull[]
Definition: polygon_type.cc:1064
AbstractLineImp::data
LineData data() const
Get the LineData for this AbstractLineImp.
Definition: line_imp.cc:359
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
ObjectImp::inherits
bool inherits(const ObjectImpType *t) const
Returns true if this ObjectImp inherits the ObjectImp type represented by t.
Definition: object_imp.cc:279
PolygonBNPType::move
void move(ObjectTypeCalcer &o, const Coordinate &to, const KigDocument &d) const
Definition: polygon_type.cc:219
OpenPolygonType::move
void move(ObjectTypeCalcer &o, const Coordinate &to, const KigDocument &d) const
Definition: polygon_type.cc:330
PolygonBCVType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:384
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE(SegmentAxisType)
PolygonBCVType::instance
static const PolygonBCVType * instance()
Definition: polygon_type.cc:378
point_imp.h
ArgsParserObjectType
This is a convenience subclass of ObjectType that a type should inherit from if its parents can be sp...
Definition: object_type.h:113
polygon_type.h
polygonlineintersection
int polygonlineintersection(const std::vector< Coordinate > &ppoints, const Coordinate a, const Coordinate b, bool boundleft, bool boundright, bool inside, bool openpolygon, double &t1, double &t2, std::vector< Coordinate >::const_iterator &intersectionside)
Definition: polygon_type.cc:712
ObjectType::inherits
virtual bool inherits(int type) const
Definition: object_type.cc:64
OpenPolygonalImp
An ObjectImp representing an open polygonal.
Definition: polygon_imp.h:157
AbstractLineImp
An ObjectImp class that is the base of the line-like ObjectImp's: SegmentImp, LineImp and RayImp...
Definition: line_imp.h:31
LineData
Simple class representing a line.
Definition: misc/common.h:49
PolygonBNPType::isDefinedOnOrThrough
bool isDefinedOnOrThrough(const ObjectImp *o, const Args &parents) const
Supposing that parents would be given as parents to this type's calc function, this function returns ...
Definition: polygon_type.cc:189
polygon_imp.h
LineData::b
Coordinate b
Another point on the line.
Definition: misc/common.h:68
PolygonVertexType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:999
PolygonSideType
Definition: polygon_type.h:190
PolygonLineIntersectionType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:538
PolygonBCVType::canMove
bool canMove(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:456
RayImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the RayImp type.
Definition: line_imp.cc:562
TriangleB3PType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:65
TriangleB3PType::canMove
bool canMove(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:86
PolygonBCVType::moveReferencePoint
const Coordinate moveReferencePoint(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:482
CPolygonalLineIntersectionType
Definition: polygon_type.h:158
OPolygonalLineIntersectionType
Definition: polygon_type.h:148
ClosedPolygonalImp::stype
static const ObjectImpType * stype()
Definition: polygon_imp.cc:678
PointImp::coordinate
const Coordinate & coordinate() const
Get the coordinate of this PointImp.
Definition: point_imp.h:50
argsspecOPolygonalLineIntersection
static const ArgsParser::spec argsspecOPolygonalLineIntersection[]
Definition: polygon_type.cc:624
OpenPolygonType::isFreelyTranslatable
bool isFreelyTranslatable(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:320
IntImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the IntImp type.
Definition: bogus_imp.cc:278
PolygonPolygonIntersectionType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:851
argsspecCPolygonalLineIntersection
static const ArgsParser::spec argsspecCPolygonalLineIntersection[]
Definition: polygon_type.cc:656
ObjectTypeCalcer
This is an ObjectCalcer that uses one of the various ObjectType's to calculate its ObjectImp...
Definition: object_calcer.h:183
AbstractPolygonImp::points
const std::vector< Coordinate > points() const
Returns the vector with polygon points.
Definition: polygon_imp.cc:571
PolygonBNPType::sortArgs
std::vector< ObjectCalcer * > sortArgs(const std::vector< ObjectCalcer * > &args) const
Definition: polygon_type.cc:194
IntImp
This ObjectImp is a BogusImp containing only an int value.
Definition: bogus_imp.h:128
PolygonBCVType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:425
OpenPolygonType
Open Polygon (Polyline, Polygonal Line)
Definition: polygon_type.h:73
TriangleB3PType::isFreelyTranslatable
bool isFreelyTranslatable(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:91
PolygonPolygonIntersectionType
Definition: polygon_type.h:168
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
ConvexHullType::instance
static const ConvexHullType * instance()
Definition: polygon_type.cc:1081
ArgsParserObjectType::margsparser
const ArgsParser margsparser
Definition: object_type.h:117
OpenPolygonalImp::stype
static const ObjectImpType * stype()
Definition: polygon_imp.cc:696
PolygonPolygonIntersectionType::instance
static const PolygonPolygonIntersectionType * instance()
Definition: polygon_type.cc:845
OpenPolygonType::instance
static const OpenPolygonType * instance()
Definition: polygon_type.cc:267
PolygonSideType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:1057
argsspecPolygonLineIntersection
static const ArgsParser::spec argsspecPolygonLineIntersection[]
Definition: polygon_type.cc:505
TriangleB3PType::instance
static const TriangleB3PType * instance()
Definition: polygon_type.cc:59
ConvexHullType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:1087
OpenPolygonType::impRequirement
const ObjectImpType * impRequirement(const ObjectImp *o, const Args &parents) const
Supposing that parents would be given as parents to this type's calc function, this function returns ...
Definition: polygon_type.cc:295
TriangleB3PType::movableParents
std::vector< ObjectCalcer * > movableParents(const ObjectTypeCalcer &ourobj) const
Definition: polygon_type.cc:122
PolygonBCVType::move
void move(ObjectTypeCalcer &o, const Coordinate &to, const KigDocument &d) const
Definition: polygon_type.cc:468
bogus_imp.h
PointImp
An ObjectImp representing a point.
Definition: point_imp.h:27
Args
std::vector< const ObjectImp * > Args
Definition: objects/common.h:47
AbstractPolygonImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the PolygonImp type.
Definition: polygon_imp.cc:651
PolygonLineIntersectionType::instance
static const PolygonLineIntersectionType * instance()
Definition: polygon_type.cc:532
PolygonBNPType::movableParents
std::vector< ObjectCalcer * > movableParents(const ObjectTypeCalcer &ourobj) const
Definition: polygon_type.cc:238
OpenPolygonType::sortArgs
std::vector< ObjectCalcer * > sortArgs(const std::vector< ObjectCalcer * > &args) const
Definition: polygon_type.cc:305
PolygonPolygonIntersectionType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:968
LineData::a
Coordinate a
One point on the line.
Definition: misc/common.h:64
OPolygonalLineIntersectionType::instance
static const OPolygonalLineIntersectionType * instance()
Definition: polygon_type.cc:645
PolygonBCVType::impRequirement
const ObjectImpType * impRequirement(const ObjectImp *o, const Args &parents) const
Supposing that parents would be given as parents to this type's calc function, this function returns ...
Definition: polygon_type.cc:430
ArgsParser::checkArgs
bool checkArgs(const std::vector< ObjectCalcer * > &os) const
Definition: argsparser.cpp:222
FilledPolygonImp::stype
static const ObjectImpType * stype()
Definition: polygon_imp.cc:660
SegmentImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the SegmentImp type.
Definition: line_imp.cc:545
PolygonBNPType::impRequirement
const ObjectImpType * impRequirement(const ObjectImp *o, const Args &parents) const
Supposing that parents would be given as parents to this type's calc function, this function returns ...
Definition: polygon_type.cc:184
triangle_constructstatement2
static const char triangle_constructstatement2[]
Definition: polygon_type.cc:39
ArgsParser::spec
Definition: argsparser.h:113
PolygonBCVType::isDefinedOnOrThrough
bool isDefinedOnOrThrough(const ObjectImp *o, const Args &parents) const
Supposing that parents would be given as parents to this type's calc function, this function returns ...
Definition: polygon_type.cc:441
object_calcer.h
ObjectType
The ObjectType class is a thing that represents the "behaviour" for a certain type.
Definition: object_type.h:32
PolygonVertexType
Definition: polygon_type.h:179
TriangleB3PType
Triangle by its vertices.
Definition: polygon_type.h:26
argsspecTriangleB3P
static const struct ArgsParser::spec argsspecTriangleB3P[]
Definition: polygon_type.cc:41
PolygonSideType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:1042
PolygonBNPType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:179
computeConvexHull
std::vector< Coordinate > computeConvexHull(const std::vector< Coordinate > &points)
Definition: polygon_imp.cc:990
Coordinate::invalidCoord
static Coordinate invalidCoord()
Create an invalid Coordinate.
Definition: coordinate.cpp:171
OPolygonalLineIntersectionType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:651
argsspecPolygonPolygonIntersection
static const ArgsParser::spec argsspecPolygonPolygonIntersection[]
Definition: polygon_type.cc:826
TriangleB3PType::move
void move(ObjectTypeCalcer &o, const Coordinate &to, const KigDocument &d) const
Definition: polygon_type.cc:99
CPolygonalLineIntersectionType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:683
PolygonBCVType
Polygon by center and vertex.
Definition: polygon_type.h:99
PolygonBNPType::moveReferencePoint
const Coordinate moveReferencePoint(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:231
OpenPolygonType::movableParents
std::vector< ObjectCalcer * > movableParents(const ObjectTypeCalcer &ourobj) const
Definition: polygon_type.cc:349
PointImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing PointImp's.
Definition: point_imp.cc:159
OpenPolygonType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:273
line_imp.h
TriangleB3PType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:81
AbstractPolygonImp::isTwisted
bool isTwisted() const
Definition: polygon_imp.cc:845
ConvexHullType
Definition: polygon_type.h:201
PolygonSideType::instance
static const PolygonSideType * instance()
Definition: polygon_type.cc:1036
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
PolygonLineIntersectionType
Definition: polygon_type.h:133
argsspecPolygonSide
static const ArgsParser::spec argsspecPolygonSide[]
Definition: polygon_type.cc:1018
argsspecPolygonVertex
static const ArgsParser::spec argsspecPolygonVertex[]
Definition: polygon_type.cc:975
OpenPolygonType::canMove
bool canMove(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:315
AbstractLineImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the AbstractLineImp type.
Definition: line_imp.cc:520
PolygonBNPType::instance
static const PolygonBNPType * instance()
Definition: polygon_type.cc:151
ObjectTypeCalcer::parents
std::vector< ObjectCalcer * > parents() const
Returns the parent ObjectCalcer's of this ObjectCalcer.
Definition: object_calcer.cc:105
Coordinate::x
double x
X Component.
Definition: coordinate.h:126
PolygonBCVType::movableParents
std::vector< ObjectCalcer * > movableParents(const ObjectTypeCalcer &ourobj) const
Definition: polygon_type.cc:491
PolygonVertexType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:1011
OpenPolygonType::isDefinedOnOrThrough
bool isDefinedOnOrThrough(const ObjectImp *o, const Args &parents) const
Supposing that parents would be given as parents to this type's calc function, this function returns ...
Definition: polygon_type.cc:300
OpenPolygonType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: polygon_type.cc:290
PolygonBNPType
Polygon by its vertices.
Definition: polygon_type.h:47
Coordinate::y
double y
Y Component.
Definition: coordinate.h:129
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
OpenPolygonType::moveReferencePoint
const Coordinate moveReferencePoint(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:342
AbstractPolygonImp
An ObjectImp representing a polygon.
Definition: polygon_imp.h:28
FilledPolygonImp
An ObjectImp representing a filled polygon.
Definition: polygon_imp.h:101
TriangleB3PType::moveReferencePoint
const Coordinate moveReferencePoint(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:115
triangle_constructstatement
static const char triangle_constructstatement[]
Definition: polygon_type.cc:38
PolygonBCVType::isFreelyTranslatable
bool isFreelyTranslatable(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:461
PolygonBNPType::isFreelyTranslatable
bool isFreelyTranslatable(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:209
PolygonLineIntersectionType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: polygon_type.cc:561
PolygonVertexType::instance
static const PolygonVertexType * instance()
Definition: polygon_type.cc:993
uint
unsigned int uint
Definition: object_imp.h:87
PolygonBCVType::sortArgs
std::vector< ObjectCalcer * > sortArgs(const std::vector< ObjectCalcer * > &args) const
Definition: polygon_type.cc:446
PolygonBNPType::canMove
bool canMove(const ObjectTypeCalcer &o) const
Definition: polygon_type.cc:204
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
SegmentImp
An ObjectImp representing a segment.
Definition: line_imp.h:81
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:12:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal