1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes 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.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2009 Henrik Tidefelt
23 #include "Shapes_Lang_decls.h"
24 #include "Shapes_Computation_decls.h"
25 #include "Shapes_Kernel_decls.h"
26 #include "Shapes_Concrete_decls.h"
27 #include "Shapes_Ast_decls.h"
31 #include "pdfstructure.h"
32 #include "shapesvalue.h"
33 #include "environment.h"
34 #include "charptrless.h"
35 #include "functiontypes.h"
36 #include "elementarycoords.h"
37 #include "statetypes.h"
49 Concrete::Time
computeDt( Concrete::Length segLength
); // it is sufficient to provide an over-estimate of the segment's length
50 Concrete::Time
straightLineArcTime( double fraction
);
54 class PolarHandleBase
: public Lang::Value
58 virtual ~PolarHandleBase( );
63 class PolarHandle2D
: public Lang::PolarHandleBase
66 RefCountPtr
< const Kernel::PolarHandlePromise
> rPromise_
;
68 PolarHandle2D( const RefCountPtr
< const Kernel::PolarHandlePromise
> & rPromise
, double a
);
69 virtual ~PolarHandle2D( );
70 virtual void show( std::ostream
& os
) const;
71 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
74 class PolarHandle2DFree_a
: public Lang::PolarHandleBase
77 RefCountPtr
< const Kernel::PolarHandlePromise
> rPromise_
;
78 PolarHandle2DFree_a( const RefCountPtr
< const Kernel::PolarHandlePromise
> & rPromise
);
79 virtual ~PolarHandle2DFree_a( );
80 virtual void show( std::ostream
& os
) const;
81 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
84 class PolarHandle2DFree_r
: public Lang::PolarHandleBase
87 RefCountPtr
< const Kernel::PolarHandlePromise
> defaultModulus_
;
89 PolarHandle2DFree_r( const RefCountPtr
< const Kernel::PolarHandlePromise
> & defaultModulus
, double a
);
90 virtual ~PolarHandle2DFree_r( );
91 virtual void show( std::ostream
& os
) const;
92 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
95 class PolarHandle2DFree_ra
: public Lang::PolarHandleBase
98 RefCountPtr
< const Kernel::PolarHandlePromise
> defaultModulus_
;
99 PolarHandle2DFree_ra( const RefCountPtr
< const Kernel::PolarHandlePromise
> & defaultModulus
);
100 virtual ~PolarHandle2DFree_ra( );
101 virtual void show( std::ostream
& os
) const;
102 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
105 class PathPoint2D
: public Lang::Geometric2D
108 Kernel::ValueRef rear_
;
109 RefCountPtr
< const Lang::Coords2D
> mid_
;
110 Kernel::ValueRef front_
;
111 PathPoint2D( const PathPoint2D
& orig
);
112 PathPoint2D( RefCountPtr
< const Lang::Coords2D
> mid
);
113 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
114 virtual RefCountPtr
< const Lang::Geometric2D
> transformed( const Lang::Transform2D
& tf
, const RefCountPtr
< const Lang::Geometric2D
> & self
) const;
115 virtual RefCountPtr
< const Lang::Geometric3D
> to3D( const RefCountPtr
< const Lang::Geometric2D
> & self
) const;
116 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
121 class Path2D
: public Lang::Geometric2D
130 bool isClosed( ) const;
131 virtual RefCountPtr
< const Lang::Geometric2D
> transformed( const Lang::Transform2D
& tf
, const RefCountPtr
< const Lang::Geometric2D
> & self
) const;
132 virtual RefCountPtr
< const Lang::Geometric3D
> to3D( const RefCountPtr
< const Lang::Geometric2D
> & self
) const;
133 virtual RefCountPtr
< const Lang::Path2D
> typed_transformed( const Lang::Transform2D
& tf
) const = 0;
134 virtual RefCountPtr
< const Lang::Path3D
> typed_to3D( const RefCountPtr
< const Lang::Path2D
> & self
) const = 0;
135 virtual void writePath( std::ostream
& os
) const = 0;
136 virtual void elementaryJob( std::stack
< const Lang::Value
* > * nodeStack
, Lang::ElementaryPath2D
* pth
, Concrete::Coords2D
* basePoint
) const = 0;
141 class CompositePath2D
: public Lang::Path2D
144 mutable RefCountPtr
< const ElementaryPath2D
> elementaryPath_
;
147 virtual ~CompositePath2D( );
148 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
150 virtual void writePath( std::ostream
& os
) const;
151 virtual RefCountPtr
< const Lang::Path2D
> typed_transformed( const Lang::Transform2D
& tf
) const;
152 virtual RefCountPtr
< const Lang::Path3D
> typed_to3D( const RefCountPtr
< const Lang::Path2D
> & self
) const;
153 RefCountPtr
< const Lang::ElementaryPath2D
> getElementaryPath( ) const;
154 virtual void show( std::ostream
& os
) const;
156 void computeElementaryPath( ) const;
159 class ClosedPath2D
: public Lang::CompositePath2D
162 RefCountPtr
< const Lang::Path2D
> openPath_
;
163 ClosedPath2D( RefCountPtr
< const Lang::Path2D
> openPath
);
164 virtual ~ClosedPath2D( );
165 virtual void elementaryJob( std::stack
< const Lang::Value
* > * nodeStack
, Lang::ElementaryPath2D
* pth
, Concrete::Coords2D
* basePoint
) const;
166 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
169 class ElementaryPath2D
: public PtrOwner_back_Access
< std::list
< Concrete::PathPoint2D
* > >, public Lang::Path2D
174 virtual ~ElementaryPath2D( );
175 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
176 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::ElementaryPath2D
> & selfRef
) const;
178 virtual void writePath( std::ostream
& os
) const;
179 virtual void writeInputForm( std::ostream
& os
) const;
180 virtual RefCountPtr
< const Lang::ElementaryPath2D
> elementaryTransformed( const Lang::Transform2D
& tf
) const;
181 virtual RefCountPtr
< const Lang::ElementaryPath3D
> elementaryTransformed( const Lang::Transform3D
& tf
) const;
182 virtual RefCountPtr
< const Lang::Path2D
> typed_transformed( const Lang::Transform2D
& tf
) const;
183 virtual RefCountPtr
< const Lang::Path3D
> typed_to3D( const RefCountPtr
< const Lang::Path2D
> & self
) const;
184 virtual RefCountPtr
< const Lang::Geometric3D
> to3D( const RefCountPtr
< const Lang::Geometric2D
> & self
) const;
185 virtual void elementaryJob( std::stack
< const Lang::Value
* > * nodeStack
, Lang::ElementaryPath2D
* pth
, Concrete::Coords2D
* basePoint
) const;
187 size_t duration( ) const;
188 bool controllingMaximizer( const Lang::FloatPair
& d
, Lang::Coords2D
* dst
) const;
189 bool boundingRectangle( Concrete::Coords2D
* dstll
, Concrete::Coords2D
* dstur
) const;
190 bool lineSegmentIntersection( Concrete::Time
* dstSelf
, Concrete::Time
* dstLine
, const Concrete::Coords2D
& l0
, const Concrete::Coords2D
& l1
) const;
192 RefCountPtr
< const Lang::Coords2D
> point( Concrete::Time t
) const;
193 RefCountPtr
< const Lang::Length
> speed( Concrete::Time t
) const;
194 RefCountPtr
< const Lang::Length
> reverse_speed( Concrete::Time t
) const;
195 RefCountPtr
< const Lang::FloatPair
> direction( Concrete::Time t
) const;
196 RefCountPtr
< const Lang::FloatPair
> reverse_direction( Concrete::Time t
) const;
197 RefCountPtr
< const Lang::Length
> radiusOfCurvature( Concrete::Time t
) const;
198 RefCountPtr
< const Lang::Length
> reverse_radiusOfCurvature( Concrete::Time t
) const;
200 RefCountPtr
< const Lang::Coords2D
> discreteMean( ) const;
201 RefCountPtr
< const Lang::Coords2D
> continuousMean( ) const;
202 RefCountPtr
< const Lang::Coords2D
> controllingMaximizer( const Lang::FloatPair
& d
) const;
203 Concrete::Length
arcLength( ) const;
204 Concrete::Length
arcLength( Concrete::Time tFinal
) const;
205 int windingNumber( const Concrete::Coords2D
& p
) const;
207 Concrete::SplineTime
arcTime( const Concrete::Length
& t
, Concrete::Time t0
= 0 ) const;
208 Concrete::SplineTime
discreteMaximizer( const Lang::FloatPair
& d
) const;
209 Concrete::SplineTime
continuousMaximizer( const Lang::FloatPair
& d
) const;
210 Concrete::SplineTime
discreteApproximator( const Lang::Coords2D
& p
) const;
211 Concrete::SplineTime
continuousApproximator( const Lang::Coords2D
& p
) const;
212 Concrete::SplineTime
continuousApproximator( const RefCountPtr
< const Lang::ElementaryPath2D
> & p2
, RefCountPtr
< const Lang::Structure
> * dstInfo
) const;
213 Concrete::SplineTime
intersection( const RefCountPtr
< const Lang::ElementaryPath2D
> & p2
, RefCountPtr
< const Lang::Structure
> * dstInfo
) const;
215 RefCountPtr
< const Lang::ElementaryPath2D
> subpath( const Concrete::SplineTime t1
, const Concrete::SplineTime t2
) const;
216 RefCountPtr
< const Lang::ElementaryPath2D
> reverse( ) const;
217 RefCountPtr
< const Lang::ElementaryPath2D
> controlling_hull( ) const;
218 RefCountPtr
< const Lang::ElementaryPath2D
> upsample( const Computation::Upsampler2D
& sampler
) const;
220 bool isConvexPoly( Concrete::Length tol
) const;
221 bool convexPolyContains( const Concrete::Coords2D
& p
, Concrete::Length tol
) const;
223 virtual void show( std::ostream
& os
) const;
224 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
227 Concrete::Time
timeCheck( Concrete::Time t
) const;
228 void findSegment( Concrete::Time t
, Concrete::Time
* tRes
, const Concrete::PathPoint2D
** p1
, const Concrete::PathPoint2D
** p2
) const;
229 void findSegmentReverse( Concrete::Time t
, Concrete::Time
* tRes
, const Concrete::PathPoint2D
** p1
, const Concrete::PathPoint2D
** p2
) const;
230 static void pushOverlappingDeleteOther( std::list
< Computation::SegmentSectionPair2D
* > & work
, Computation::SegmentSectionPair2D
* item
);
231 static void pushCloseDeleteOther( std::list
< Computation::SegmentSectionPair2D
* > * work
, Computation::SegmentSectionPair2D
* item
, Concrete::LengthSquared closeDist
);
232 Concrete::Length
negative_arcLength( Concrete::Time tFinal
) const;
233 Concrete::SplineTime
negative_arcTime( const Concrete::Length dist
, Concrete::Time t0
= 0 ) const;
236 class PathSlider2D
: public Lang::Value
238 RefCountPtr
< const Lang::ElementaryPath2D
> path_
;
239 Concrete::SplineTime t_
;
240 Kernel::VariableHandle info_
; /* Generally, this is a void value, but it may also be a structure with information about how this slider was computed. Different computations may lead to structures with different signatures. */
242 PathSlider2D( const Lang::PathSlider2D
& orig
);
243 PathSlider2D( const RefCountPtr
< const Lang::ElementaryPath2D
> & path
);
244 PathSlider2D( const RefCountPtr
< const Lang::ElementaryPath2D
> & path
, Concrete::SplineTime t
);
245 PathSlider2D( const RefCountPtr
< const Lang::ElementaryPath2D
> & path
, Concrete::SplineTime t
, Kernel::VariableHandle info
);
246 virtual ~PathSlider2D( );
247 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
248 RefCountPtr
< const Lang::ElementaryPath2D
> getPath( ) const { return path_
; }
249 Concrete::SplineTime
getTime( ) const { return t_
; }
250 Kernel::VariableHandle
getInfo( ) const { return info_
; }
252 RefCountPtr
< Lang::PathSlider2D
> move_time( const Concrete::Time delta
) const;
253 RefCountPtr
< Lang::PathSlider2D
> move_length( const Concrete::Length delta
) const;
254 RefCountPtr
< Lang::PathSlider2D
> seek_time( const Concrete::Time val
) const;
255 RefCountPtr
< Lang::PathSlider2D
> seek_start( ) const;
256 RefCountPtr
< Lang::PathSlider2D
> seek_end( ) const;
257 RefCountPtr
< Lang::PathSlider2D
> seek_length( const Concrete::Length val
) const;
259 RefCountPtr
< const Lang::Coords2D
> point( ) const;
260 RefCountPtr
< const Lang::Length
> speed( ) const;
261 RefCountPtr
< const Lang::Length
> reverse_speed( ) const;
262 RefCountPtr
< const Lang::FloatPair
> direction( ) const;
263 RefCountPtr
< const Lang::FloatPair
> reverse_direction( ) const;
264 RefCountPtr
< const Lang::FloatPair
> normal( ) const;
265 RefCountPtr
< const Lang::FloatPair
> reverse_normal( ) const;
266 RefCountPtr
< const Lang::Length
> radiusOfCurvature( ) const;
267 RefCountPtr
< const Lang::Length
> reverse_radiusOfCurvature( ) const;
268 RefCountPtr
< const Lang::Float
> time( ) const;
269 RefCountPtr
< const Lang::Length
> length( ) const;
271 virtual RefCountPtr
< const Lang::Value
> getRear( ) const;
272 virtual RefCountPtr
< const Lang::Value
> getFront( ) const;
274 virtual void show( std::ostream
& os
) const;
275 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
280 class PathSlider2D_rear
: public Lang::PathSlider2D
282 RefCountPtr
< const Lang::Value
> rear_
;
284 PathSlider2D_rear( const Lang::PathSlider2D
& orig
, const RefCountPtr
< const Lang::Value
> & rear
);
285 virtual RefCountPtr
< const Lang::Value
> getRear( ) const;
288 class PathSlider2D_front
: public Lang::PathSlider2D
290 RefCountPtr
< const Lang::Value
> front_
;
292 PathSlider2D_front( const Lang::PathSlider2D
& orig
, const RefCountPtr
< const Lang::Value
> & front
);
293 virtual RefCountPtr
< const Lang::Value
> getFront( ) const;
296 class Connection2D
: public Lang::CompositePath2D
299 Kernel::ValueRef rear_
;
300 Kernel::ValueRef front_
;
301 Connection2D( Kernel::ValueRef rear
, Kernel::ValueRef front
);
303 virtual void elementaryJob( std::stack
< const Lang::Value
* > * nodeStack
, Lang::ElementaryPath2D
* pth
, Concrete::Coords2D
* basePoint
) const;
304 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
307 class SinglePointPath2D
: public Lang::CompositePath2D
310 Kernel::ValueRef thePoint_
;
311 SinglePointPath2D( Kernel::ValueRef thePoint
);
312 ~SinglePointPath2D( );
313 virtual void elementaryJob( std::stack
< const Lang::Value
* > * nodeStack
, Lang::ElementaryPath2D
* pth
, Concrete::Coords2D
* basePoint
) const;
314 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
317 class HeadedPath2D_helper
: public Lang::CompositePath2D
319 RefCountPtr
< const Lang::ElementaryPath2D
> bodyPath_
;
321 HeadedPath2D_helper( const RefCountPtr
< const Lang::ElementaryPath2D
> & bodyPath
);
322 ~HeadedPath2D_helper( );
323 virtual void elementaryJob( std::stack
< const Lang::Value
* > * nodeStack
, Lang::ElementaryPath2D
* pth
, Concrete::Coords2D
* basePoint
) const;
324 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
327 class HeadedPath2D
: public Lang::CompositePath2D
329 RefCountPtr
< const Lang::HeadedPath2D_helper
> bodyPath_
;
330 Kernel::ValueRef rearPathPoint_
;
331 Kernel::ValueRef frontPathPoint_
;
333 HeadedPath2D( Kernel::ValueRef rear
, const RefCountPtr
< const Lang::ElementaryPath2D
> & bodyPath
, Kernel::ValueRef front
);
335 virtual void elementaryJob( std::stack
< const Lang::Value
* > * nodeStack
, Lang::ElementaryPath2D
* pth
, Concrete::Coords2D
* basePoint
) const;
336 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
339 class MultiPath2D
: public Lang::Geometric2D
, public std::list
< RefCountPtr
< const Path2D
> >
344 MultiPath2D
* clone( ) const;
345 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
346 virtual RefCountPtr
< const Lang::Geometric2D
> transformed(const Lang::Transform2D
& tf
, const RefCountPtr
< const Lang::Geometric2D
> & self
) const;
347 virtual RefCountPtr
< const Lang::Geometric3D
> to3D( const RefCountPtr
< const Lang::Geometric2D
> & self
) const;
348 void writePath( std::ostream
& os
) const;
350 virtual void show( std::ostream
& os
) const;
351 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
356 class PathPoint3D
: public Lang::Geometric3D
359 RefCountPtr
< const Lang::Coords3D
> rear_
;
360 RefCountPtr
< const Lang::Coords3D
> mid_
;
361 RefCountPtr
< const Lang::Coords3D
> front_
;
362 PathPoint3D( const PathPoint3D
& orig
);
363 PathPoint3D( const RefCountPtr
< const Lang::Coords3D
> & mid
);
364 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
365 void elementaryJob( Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
366 virtual RefCountPtr
< const Lang::Geometric3D
> transformed( const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Geometric3D
> & self
) const;
367 virtual RefCountPtr
< const Lang::Geometric2D
> to2D( const Kernel::PassedDyn
& dyn
, const RefCountPtr
< const Lang::Geometric3D
> & self
) const;
368 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
374 class Path3D
: public Lang::Geometric3D
383 bool isClosed( ) const;
384 virtual RefCountPtr
< const Lang::Geometric3D
> transformed( const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Geometric3D
> & self
) const;
385 virtual RefCountPtr
< const Lang::Path3D
> typed_transformed( const Lang::Transform3D
& tf
) const = 0;
386 virtual RefCountPtr
< const Lang::Geometric2D
> to2D( const Kernel::PassedDyn
& dyn
, const RefCountPtr
< const Lang::Geometric3D
> & self
) const;
387 virtual RefCountPtr
< const Lang::ElementaryPath2D
> make2D( Concrete::Length eyez
) const = 0;
388 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const = 0;
393 class CompositePath3D
: public Lang::Path3D
396 mutable RefCountPtr
< const ElementaryPath3D
> elementaryPath_
;
399 virtual ~CompositePath3D( );
400 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
402 virtual RefCountPtr
< const Lang::ElementaryPath2D
> make2D( Concrete::Length eyez
) const;
403 virtual RefCountPtr
< const Lang::Path3D
> typed_transformed( const Lang::Transform3D
& tf
) const;
404 RefCountPtr
< const Lang::ElementaryPath3D
> getElementaryPath( ) const;
405 virtual void show( std::ostream
& os
) const;
407 void computeElementaryPath( ) const;
410 class Path2Din3D
: public Lang::CompositePath3D
412 RefCountPtr
< const Lang::ElementaryPath2D
> elementaryPath2D_
;
414 Path2Din3D( const RefCountPtr
< const Lang::ElementaryPath2D
> & _elementaryPath2D
);
416 virtual RefCountPtr
< const Lang::ElementaryPath2D
> make2D( Concrete::Length eyez
) const;
417 virtual RefCountPtr
< const Lang::Path3D
> typed_transformed( const Lang::Transform3D
& tf
) const;
418 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
419 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
422 class ClosedPath3D
: public Lang::CompositePath3D
425 RefCountPtr
< const Lang::Path3D
> openPath_
;
426 ClosedPath3D( RefCountPtr
< const Lang::Path3D
> openPath
);
427 virtual ~ClosedPath3D( );
428 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
429 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
432 class ElementaryPath3D
: public PtrOwner_back_Access
< std::list
< Concrete::PathPoint3D
* > >, public Lang::Path3D
436 virtual ~ElementaryPath3D( );
437 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
438 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::ElementaryPath3D
> & selfRef
) const;
440 virtual RefCountPtr
< const Lang::ElementaryPath2D
> make2D( Concrete::Length eyez
) const;
441 void dashifyIn2D( RefCountPtr
< const Lang::Group2D
> * res
, Concrete::Length eyez
, const RefCountPtr
< const Kernel::GraphicsState
> & metaState
) const;
442 virtual RefCountPtr
< const Lang::ElementaryPath3D
> elementaryTransformed( const Lang::Transform3D
& tf
) const;
443 virtual RefCountPtr
< const Lang::Path3D
> typed_transformed( const Lang::Transform3D
& tf
) const;
444 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
446 size_t duration( ) const;
447 bool controllingMaximizer( const Lang::FloatTriple
& d
, Lang::Coords3D
* dst
) const;
449 RefCountPtr
< const Lang::Coords3D
> point( Concrete::Time t
) const;
450 RefCountPtr
< const Lang::Length
> speed( Concrete::Time t
) const;
451 RefCountPtr
< const Lang::Length
> reverse_speed( Concrete::Time t
) const;
452 RefCountPtr
< const Lang::FloatTriple
> direction( Concrete::Time t
) const;
453 RefCountPtr
< const Lang::FloatTriple
> reverse_direction( Concrete::Time t
) const;
454 RefCountPtr
< const Lang::FloatTriple
> normal( Concrete::Time t
) const;
455 RefCountPtr
< const Lang::FloatTriple
> reverse_normal( Concrete::Time t
) const;
456 RefCountPtr
< const Lang::Length
> radiusOfCurvature( Concrete::Time t
) const;
457 RefCountPtr
< const Lang::Length
> reverse_radiusOfCurvature( Concrete::Time t
) const;
458 RefCountPtr
< const Lang::Length
> radiusOfTorsion( Concrete::Time t
) const;
459 RefCountPtr
< const Lang::Length
> reverse_radiusOfTorsion( Concrete::Time t
) const;
461 RefCountPtr
< const Lang::Coords3D
> discreteMean( ) const;
462 RefCountPtr
< const Lang::Coords3D
> continuousMean( ) const;
463 RefCountPtr
< const Lang::Coords3D
> controllingMaximizer( const Lang::FloatTriple
& d
) const;
464 Concrete::Length
arcLength( ) const;
465 Concrete::Length
arcLength( Concrete::Time tFinal
) const;
467 Concrete::SplineTime
arcTime( const Concrete::Length
& t
, Concrete::Time t0
= 0 ) const;
468 Concrete::SplineTime
discreteMaximizer( const Lang::FloatTriple
& d
) const;
469 Concrete::SplineTime
continuousMaximizer( const Lang::FloatTriple
& d
) const;
470 Concrete::SplineTime
discreteApproximator( const Lang::Coords3D
& p
) const;
471 Concrete::SplineTime
continuousApproximator( const Lang::Coords3D
& p
) const;
472 Concrete::SplineTime
continuousApproximator( const RefCountPtr
< const Lang::ElementaryPath3D
> & p2
, RefCountPtr
< const Lang::Structure
> * dstInfo
) const;
474 RefCountPtr
< const Lang::ElementaryPath3D
> subpath( const Concrete::SplineTime t1
, const Concrete::SplineTime t2
) const;
475 RefCountPtr
< const Lang::ElementaryPath3D
> reverse( ) const;
476 RefCountPtr
< const Lang::ElementaryPath3D
> upsample( const Computation::Upsampler3D
& sampler
) const;
478 virtual void show( std::ostream
& os
) const;
479 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
481 void getRepresentativePoints( const Lang::Transform3D
& tf
, Concrete::Coords3D
* p0
, Concrete::Coords3D
* p1
, Concrete::Coords3D
* p2
) const;
484 Concrete::Time
timeCheck( Concrete::Time t
) const;
485 void findSegment( Concrete::Time t
, Concrete::Time
* tRes
, const Concrete::PathPoint3D
** p1
, const Concrete::PathPoint3D
** p2
) const;
486 void findSegmentReverse( Concrete::Time t
, Concrete::Time
* tRes
, const Concrete::PathPoint3D
** p1
, const Concrete::PathPoint3D
** p2
) const;
487 Concrete::Length
negative_arcLength( Concrete::Time tFinal
) const;
488 Concrete::SplineTime
negative_arcTime( const Concrete::Length dist
, Concrete::Time t0
= 0 ) const;
489 static void makeSegment2D( Lang::ElementaryPath2D
* dst
, Concrete::Coords2D
** passedRear
, const Concrete::Coords3D
* p0
, const Concrete::Coords3D
* p1
, const Concrete::Coords3D
* p2
, const Concrete::Coords3D
* p3
, Concrete::Length eyez
);
490 static double viewDistortionTooBig( const Concrete::Coords3D
& p0
, const Concrete::Coords3D
& p1
, const Concrete::Coords3D
& p2
, const Concrete::Coords3D
& p3
, Concrete::Length eyez
, double threshold
);
491 static void dashifySegment( RefCountPtr
< const Lang::Group2D
> * res
, Lang::ElementaryPath3D
& newPath
, Concrete::Length remainingLength
, Concrete::Coords3D
** passedRear
, const Concrete::Coords3D
* p0
, const Concrete::Coords3D
* p1
, const Concrete::Coords3D
* p2
, const Concrete::Coords3D
* p3
, Concrete::Length eyez
, const RefCountPtr
< const Kernel::GraphicsState
> & solidState
, Lang::Dash::Iterator
& dashi
);
492 static void laterArcTime( const Concrete::Bezier
& x0
, const Concrete::Bezier
& y0
, const Concrete::Bezier
& z0
, const Concrete::Bezier
& x1
, const Concrete::Bezier
& y1
, const Concrete::Bezier
& z1
, const Concrete::Bezier
& x2
, const Concrete::Bezier
& y2
, const Concrete::Bezier
& z2
, const Concrete::Bezier
& x3
, const Concrete::Bezier
& y3
, const Concrete::Bezier
& z3
, Concrete::Time
* _t
, Concrete::Length
* l
, const Concrete::Time
& dt
);
493 static void pushCloseDeleteOther( std::list
< Computation::SegmentSectionPair3D
* > * work
, Computation::SegmentSectionPair3D
* item
, Concrete::LengthSquared closeDist
);
496 class PathSlider3D
: public Lang::Value
498 RefCountPtr
< const Lang::ElementaryPath3D
> path_
;
499 Concrete::SplineTime t_
;
500 Kernel::VariableHandle info_
; /* See comment in PathSlider2D. */
502 PathSlider3D( const Lang::PathSlider3D
& orig
);
503 PathSlider3D( const RefCountPtr
< const Lang::ElementaryPath3D
> & _path
);
504 PathSlider3D( const RefCountPtr
< const Lang::ElementaryPath3D
> & _path
, Concrete::SplineTime _t
);
505 PathSlider3D( const RefCountPtr
< const Lang::ElementaryPath3D
> & _path
, Concrete::SplineTime _t
, Kernel::VariableHandle info
);
506 virtual ~PathSlider3D( );
507 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
508 RefCountPtr
< const Lang::ElementaryPath3D
> getPath( ) const { return path_
; }
509 Concrete::SplineTime
getTime( ) const { return t_
; }
510 Kernel::VariableHandle
getInfo( ) const { return info_
; }
512 RefCountPtr
< Lang::PathSlider3D
> move_time( const Concrete::Time delta
) const;
513 RefCountPtr
< Lang::PathSlider3D
> move_length( const Concrete::Length delta
) const;
514 RefCountPtr
< Lang::PathSlider3D
> seek_time( const Concrete::Time val
) const;
515 RefCountPtr
< Lang::PathSlider3D
> seek_start( ) const;
516 RefCountPtr
< Lang::PathSlider3D
> seek_end( ) const;
517 RefCountPtr
< Lang::PathSlider3D
> seek_length( const Concrete::Length val
) const;
519 RefCountPtr
< const Lang::Coords3D
> point( ) const;
520 RefCountPtr
< const Lang::Length
> speed( ) const;
521 RefCountPtr
< const Lang::Length
> reverse_speed( ) const;
522 RefCountPtr
< const Lang::FloatTriple
> direction( ) const;
523 RefCountPtr
< const Lang::FloatTriple
> reverse_direction( ) const;
524 RefCountPtr
< const Lang::FloatTriple
> normal( ) const;
525 RefCountPtr
< const Lang::FloatTriple
> reverse_normal( ) const;
526 RefCountPtr
< const Lang::FloatTriple
> binormal( ) const;
527 RefCountPtr
< const Lang::FloatTriple
> reverse_binormal( ) const;
528 RefCountPtr
< const Lang::Length
> radiusOfCurvature( ) const;
529 RefCountPtr
< const Lang::Length
> reverse_radiusOfCurvature( ) const;
530 RefCountPtr
< const Lang::Length
> radiusOfTorsion( ) const;
531 RefCountPtr
< const Lang::Length
> reverse_radiusOfTorsion( ) const;
532 RefCountPtr
< const Lang::Float
> time( ) const;
533 RefCountPtr
< const Lang::Length
> length( ) const;
535 virtual RefCountPtr
< const Lang::Value
> getRear( ) const;
536 virtual RefCountPtr
< const Lang::Value
> getFront( ) const;
538 virtual void show( std::ostream
& os
) const;
539 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
544 class PathSlider3D_rear
: public Lang::PathSlider3D
546 RefCountPtr
< const Lang::Value
> rear_
;
548 PathSlider3D_rear( const Lang::PathSlider3D
& orig
, const RefCountPtr
< const Lang::Value
> & rear
);
549 virtual RefCountPtr
< const Lang::Value
> getRear( ) const;
552 class PathSlider3D_front
: public Lang::PathSlider3D
554 RefCountPtr
< const Lang::Value
> front_
;
556 PathSlider3D_front( const Lang::PathSlider3D
& orig
, const RefCountPtr
< const Lang::Value
> & front
);
557 virtual RefCountPtr
< const Lang::Value
> getFront( ) const;
560 class Connection3D
: public Lang::CompositePath3D
563 RefCountPtr
< const Lang::Path3D
> rear_
;
564 RefCountPtr
< const Lang::Path3D
> front_
;
565 Connection3D( const RefCountPtr
< const Lang::Path3D
> & rear
, const RefCountPtr
< const Lang::Path3D
> & front
);
567 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
568 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
571 class SinglePointPath3D
: public Lang::CompositePath3D
574 RefCountPtr
< const Lang::PathPoint3D
> thePoint_
;
575 SinglePointPath3D( const RefCountPtr
< const Lang::PathPoint3D
> & thePoint
);
576 SinglePointPath3D( const RefCountPtr
< const Lang::Coords3D
> & mid
);
577 ~SinglePointPath3D( );
578 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
579 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
582 class HeadedPath3D_helper
: public Lang::CompositePath3D
584 RefCountPtr
< const Lang::ElementaryPath3D
> bodyPath_
;
586 HeadedPath3D_helper( const RefCountPtr
< const Lang::ElementaryPath3D
> & bodyPath
);
587 ~HeadedPath3D_helper( );
588 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
589 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
592 class HeadedPath3D
: public Lang::CompositePath3D
594 RefCountPtr
< const Lang::HeadedPath3D_helper
> bodyPath_
;
595 RefCountPtr
< const Lang::SinglePointPath3D
> rearPathPoint_
;
596 RefCountPtr
< const Lang::SinglePointPath3D
> frontPathPoint_
;
598 HeadedPath3D( Kernel::ValueRef rear
, const RefCountPtr
< const Lang::ElementaryPath3D
> & bodyPath
, Kernel::ValueRef front
);
600 virtual void elementaryJob( std::stack
< const Lang::Path3D
* > * nodeStack
, Lang::ElementaryPath3D
* pth
, Concrete::Coords3D
* basePoint
) const;
601 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
604 class MultiPath3D
: public Lang::Geometric3D
, public std::list
< RefCountPtr
< const Path3D
> >
609 MultiPath3D
* clone( ) const;
610 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
611 virtual RefCountPtr
< const Lang::Geometric3D
> transformed( const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Geometric3D
> & self
) const;
612 virtual RefCountPtr
< const Lang::Geometric2D
> to2D( const Kernel::PassedDyn
& dyn
, const RefCountPtr
< const Lang::Geometric3D
> & self
) const;
614 virtual void show( std::ostream
& os
) const;
615 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
624 class PolarHandlePromise
627 PolarHandlePromise( );
628 virtual ~PolarHandlePromise( );
629 virtual double force( const Concrete::PathPoint2D
* specialUnitP0
, const Concrete::PathPoint2D
* specialUnitP1
, bool reverse
) const = 0;
630 virtual void gcMark( Kernel::GCMarkedSet
& marked
) const = 0;
631 virtual void show( std::ostream
& os
) const = 0;
634 class PolarHandleEmptyPromise
: public PolarHandlePromise
637 PolarHandleEmptyPromise( );
638 virtual ~PolarHandleEmptyPromise( );
639 virtual double force( const Concrete::PathPoint2D
* specialUnitP0
, const Concrete::PathPoint2D
* specialUnitP1
, bool reverse
) const;
640 virtual void gcMark( Kernel::GCMarkedSet
& marked
) const;
641 virtual void show( std::ostream
& os
) const;
644 class PolarHandleTruePromise
: public PolarHandlePromise
646 Kernel::Thunk
* thunk_
; /* this thunk always waits to be forced, since it will be evaluated in different dynamic contexts each time */
648 PolarHandleTruePromise( Kernel::Thunk
* thunk
);
649 virtual ~PolarHandleTruePromise( );
650 virtual double force( const Concrete::PathPoint2D
* specialUnitP0
, const Concrete::PathPoint2D
* specialUnitP1
, bool reverse
) const;
651 virtual void gcMark( Kernel::GCMarkedSet
& marked
) const;
652 virtual void show( std::ostream
& os
) const;
662 enum HandleState
{ COMPLETE
= 0x0000, FREE_ANGLE
= 0x0001, FREE_MODULUS
= 0x0002, FREE
= 0x0003, UNFORCED_M
= 0x0004, UNFORCED_A
= 0x0008 };
666 Concrete::Length rearModulus_
;
667 RefCountPtr
< const Kernel::PolarHandlePromise
> rearModulusPromise_
;
671 Concrete::Length frontModulus_
;
672 RefCountPtr
< const Kernel::PolarHandlePromise
> frontModulusPromise_
;
674 double defaultAngle_
;
676 Concrete::Coords2D
* rear_
;
677 Concrete::Coords2D
* mid_
;
678 Concrete::Coords2D
* front_
;
680 PathPoint2D( const Concrete::PathPoint2D
& orig
);
681 PathPoint2D( Concrete::Coords2D
* _mid
);
682 PathPoint2D( Concrete::Length midx
, Concrete::Length midy
);
684 Concrete::PathPoint2D
* transformed( const Lang::Transform2D
& tf
) const;
685 Concrete::PathPoint3D
* transformed( const Lang::Transform3D
& tf
) const; // treat as z = 0
686 Concrete::PathPoint3D
* typed_to3D( ) const; // treat as z = 0
692 Concrete::Coords3D
* rear_
;
693 Concrete::Coords3D
* mid_
;
694 Concrete::Coords3D
* front_
;
696 PathPoint3D( const Concrete::PathPoint3D
& orig
);
697 PathPoint3D( Concrete::Coords3D
* mid
);
698 PathPoint3D( const Concrete::Coords2D
& mid
); // treat as z = 0
699 PathPoint3D( Concrete::Length midx
, Concrete::Length midy
, Concrete::Length midz
);
701 Concrete::PathPoint3D
* transformed( const Lang::Transform3D
& tf
) const;
702 Concrete::PathPoint2D
* make2D( Concrete::Length eyez
) const;