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 Henrik Tidefelt
23 using namespace Shapes
;
25 Lang::Tagged2D::Tagged2D( const RefCountPtr
< const Lang::Symbol
> & key
)
26 : key_( key
->getKey( ) )
29 Lang::Tagged2D::Tagged2D( const Lang::Symbol::KeyType key
)
33 Lang::Tagged2D::~Tagged2D( )
37 Lang::Tagged2D::key( ) const
43 Lang::TaggedValue2D::TaggedValue2D( const RefCountPtr
< const Lang::Symbol
> & key
, const RefCountPtr
< const Lang::Value
> & val
)
44 : Lang::Tagged2D( key
), val_( val
)
47 Lang::TaggedValue2D::TaggedValue2D( const Lang::Symbol::KeyType key
, const RefCountPtr
< const Lang::Value
> & val
)
48 : Lang::Tagged2D( key
), val_( val
)
51 Lang::TaggedValue2D::~TaggedValue2D( )
55 Lang::TaggedValue2D::shipout( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
) const
60 RefCountPtr
< const Lang::ElementaryPath2D
>
61 Lang::TaggedValue2D::bbox( Lang::Drawable2D::BoxType boxType
) const
63 return Lang::THE_EMPTYPATH2D
;
66 RefCountPtr
< const Lang::Geometric3D
>
67 Lang::TaggedValue2D::to3D( const RefCountPtr
< const Lang::Geometric2D
> & self
) const
69 return RefCountPtr
< const Lang::Geometric3D
>( new Lang::TaggedValue3D( key_
, val_
) );
73 Lang::TaggedValue2D::findTags( std::vector
< Kernel::ValueRef
> * dst
, const Kernel::PassedDyn
& dyn
, Lang::Symbol::KeyType key
, const Lang::Transform2D
& tf
) const
75 // tf is ignored for this type of tag.
78 dst
->push_back( val_
);
83 Lang::TaggedValue2D::findOneTag( Kernel::EvalState
* evalState
, Lang::Symbol::KeyType key
, const Lang::Transform2D
& tf
) const
85 // tf is ignored for this type of tag.
88 Kernel::ContRef cont
= evalState
->cont_
;
89 cont
->takeValue( val_
,
97 Lang::TaggedValue2D::show( std::ostream
& os
) const
101 os
<< "Value with the tag " << Lang::Symbol::nameFromKey( key_
).getPtr( ) ;
105 os
<< "Value with unique tag." ;
109 RefCountPtr
< const Lang::Value
>
110 Lang::TaggedValue2D::val( ) const
116 Lang::TaggedValue2D::gcMark( Kernel::GCMarkedSet
& marked
)
118 const_cast< Lang::Value
* >( val_
.getPtr( ) )->gcMark( marked
);
122 Lang::TaggedGeometric2D::TaggedGeometric2D( const RefCountPtr
< const Lang::Symbol
> & key
, const RefCountPtr
< const Lang::Geometric2D
> & val
)
123 : Lang::Tagged2D( key
), val_( val
)
126 Lang::TaggedGeometric2D::TaggedGeometric2D( const Lang::Symbol::KeyType key
, const RefCountPtr
< const Lang::Geometric2D
> & val
)
127 : Lang::Tagged2D( key
), val_( val
)
130 Lang::TaggedGeometric2D::~TaggedGeometric2D( )
134 Lang::TaggedGeometric2D::shipout( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
) const
139 RefCountPtr
< const Lang::ElementaryPath2D
>
140 Lang::TaggedGeometric2D::bbox( Lang::Drawable2D::BoxType boxType
) const
142 return Lang::THE_EMPTYPATH2D
;
145 RefCountPtr
< const Lang::Geometric3D
>
146 Lang::TaggedGeometric2D::to3D( const RefCountPtr
< const Lang::Geometric2D
> & self
) const
148 return RefCountPtr
< const Lang::Geometric3D
>( new Lang::TaggedGeometric3D( key_
, val_
->to3D( val_
) ) );
152 Lang::TaggedGeometric2D::findTags( std::vector
< Kernel::ValueRef
> * dst
, const Kernel::PassedDyn
& dyn
, Lang::Symbol::KeyType key
, const Lang::Transform2D
& tf
) const
154 // tf is ignored for this type of tag.
157 dst
->push_back( val_
->transformed( tf
, val_
) );
162 Lang::TaggedGeometric2D::findOneTag( Kernel::EvalState
* evalState
, Lang::Symbol::KeyType key
, const Lang::Transform2D
& tf
) const
164 // tf is ignored for this type of tag.
167 Kernel::ContRef cont
= evalState
->cont_
;
168 cont
->takeValue( val_
->transformed( tf
, val_
),
176 Lang::TaggedGeometric2D::show( std::ostream
& os
) const
180 os
<< "Geometric value with the tag " << Lang::Symbol::nameFromKey( key_
).getPtr( ) ;
184 os
<< "Geometric value with unique tag." ;
189 Lang::TaggedGeometric2D::gcMark( Kernel::GCMarkedSet
& marked
)
191 const_cast< Lang::Geometric2D
* >( val_
.getPtr( ) )->gcMark( marked
);
195 Lang::TaggedDrawable2D::TaggedDrawable2D( const RefCountPtr
< const Lang::Symbol
> & key
, const RefCountPtr
< const Lang::Drawable2D
> & val
)
196 : Lang::Tagged2D( key
), val_( val
)
199 Lang::TaggedDrawable2D::TaggedDrawable2D( const Lang::Symbol::KeyType key
, const RefCountPtr
< const Lang::Drawable2D
> & val
)
200 : Lang::Tagged2D( key
), val_( val
)
203 Lang::TaggedDrawable2D::~TaggedDrawable2D( )
207 Lang::TaggedDrawable2D::shipout( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
) const
209 val_
->shipout( os
, pdfState
, tf
);
212 RefCountPtr
< const Lang::ElementaryPath2D
>
213 Lang::TaggedDrawable2D::bbox( Lang::Drawable2D::BoxType boxType
) const
215 return val_
->bbox( boxType
);
218 RefCountPtr
< const Lang::Geometric3D
>
219 Lang::TaggedDrawable2D::to3D( const RefCountPtr
< const Lang::Geometric2D
> & self
) const
221 return RefCountPtr
< const Lang::Geometric3D
>( new Lang::TaggedDrawable3D
223 RefCountPtr
< const Lang::Drawable3D
>( new Lang::Drawable2Din3D( val_
) ) ) );
227 Lang::TaggedDrawable2D::findTags( std::vector
< Kernel::ValueRef
> * dst
, const Kernel::PassedDyn
& dyn
, Lang::Symbol::KeyType key
, const Lang::Transform2D
& tf
) const
229 // tf is ignored for this type of tag.
232 dst
->push_back( val_
->transformed( tf
, val_
) );
237 Lang::TaggedDrawable2D::findOneTag( Kernel::EvalState
* evalState
, Lang::Symbol::KeyType key
, const Lang::Transform2D
& tf
) const
239 // tf is ignored for this type of tag.
242 Kernel::ContRef cont
= evalState
->cont_
;
243 cont
->takeValue( val_
->transformed( tf
, val_
),
251 Lang::TaggedDrawable2D::show( std::ostream
& os
) const
255 os
<< "Drawable value with the tag " << Lang::Symbol::nameFromKey( key_
).getPtr( ) ;
259 os
<< "Drawable value with unique tag." ;
264 Lang::TaggedDrawable2D::gcMark( Kernel::GCMarkedSet
& marked
)
266 const_cast< Lang::Drawable2D
* >( val_
.getPtr( ) )->gcMark( marked
);
270 Lang::Tagged3D::Tagged3D( const RefCountPtr
< const Lang::Symbol
> & key
)
271 : key_( key
->getKey( ) )
274 Lang::Tagged3D::Tagged3D( const Lang::Symbol::KeyType key
)
278 Lang::Tagged3D::~Tagged3D( )
281 Lang::Symbol::KeyType
282 Lang::Tagged3D::key( ) const
288 Lang::TaggedValue3D::TaggedValue3D( const RefCountPtr
< const Lang::Symbol
> & key
, const RefCountPtr
< const Lang::Value
> & val
)
289 : Lang::Tagged3D( key
), val_( val
)
292 Lang::TaggedValue3D::TaggedValue3D( const Lang::Symbol::KeyType key
, const RefCountPtr
< const Lang::Value
> & val
)
293 : Lang::Tagged3D( key
), val_( val
)
296 Lang::TaggedValue3D::~TaggedValue3D( )
299 RefCountPtr
< const Lang::Drawable2D
>
300 Lang::TaggedValue3D::typed_to2D( const Kernel::PassedDyn
& dyn
, const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Drawable3D
> & self
) const
302 return RefCountPtr
< const Lang::Drawable2D
>( new Lang::TaggedValue2D( key_
, val_
) );
306 Lang::TaggedValue3D::polygonize( std::list
< RefCountPtr
< Computation::PaintedPolygon3D
> > * zBufPile
, std::list
< RefCountPtr
< Computation::StrokedLine3D
> > * linePile
, const Kernel::PassedDyn
& dyn
, const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Drawable3D
> & self
) const
308 // Note that polygonization eats tags.
312 Lang::TaggedValue3D::findTags( std::vector
< Kernel::ValueRef
> * dst
, const Kernel::PassedDyn
& dyn
, Lang::Symbol::KeyType key
, const Lang::Transform3D
& tf
) const
314 // tf is ignored for this type of tag.
317 dst
->push_back( val_
);
322 Lang::TaggedValue3D::findOneTag( Kernel::EvalState
* evalState
, Lang::Symbol::KeyType key
, const Lang::Transform3D
& tf
) const
324 // tf is ignored for this type of tag.
327 Kernel::ContRef cont
= evalState
->cont_
;
328 cont
->takeValue( val_
,
336 Lang::TaggedValue3D::show( std::ostream
& os
) const
340 os
<< "Value (3D) with the tag " << Lang::Symbol::nameFromKey( key_
).getPtr( ) ;
344 os
<< "Value (3D) with unique tag." ;
349 Lang::TaggedValue3D::gcMark( Kernel::GCMarkedSet
& marked
)
351 const_cast< Lang::Value
* >( val_
.getPtr( ) )->gcMark( marked
);
355 Lang::TaggedGeometric3D::TaggedGeometric3D( const RefCountPtr
< const Lang::Symbol
> & key
, const RefCountPtr
< const Lang::Geometric3D
> & val
)
356 : Lang::Tagged3D( key
), val_( val
)
359 Lang::TaggedGeometric3D::TaggedGeometric3D( const Lang::Symbol::KeyType key
, const RefCountPtr
< const Lang::Geometric3D
> & val
)
360 : Lang::Tagged3D( key
), val_( val
)
363 Lang::TaggedGeometric3D::~TaggedGeometric3D( )
367 RefCountPtr
< const Lang::Drawable2D
>
368 Lang::TaggedGeometric3D::typed_to2D( const Kernel::PassedDyn
& dyn
, const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Drawable3D
> & self
) const
370 RefCountPtr
< const Lang::Geometric3D
> tfVal
= val_
->transformed( tf
, val_
);
371 return RefCountPtr
< const Lang::Drawable2D
>( new Lang::TaggedGeometric2D( key_
, tfVal
->to2D( dyn
, tfVal
) ) );
375 Lang::TaggedGeometric3D::polygonize( std::list
< RefCountPtr
< Computation::PaintedPolygon3D
> > * zBufPile
, std::list
< RefCountPtr
< Computation::StrokedLine3D
> > * linePile
, const Kernel::PassedDyn
& dyn
, const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Drawable3D
> & self
) const
377 // Note that polygonization eats tags.
381 Lang::TaggedGeometric3D::findTags( std::vector
< Kernel::ValueRef
> * dst
, const Kernel::PassedDyn
& dyn
, Lang::Symbol::KeyType key
, const Lang::Transform3D
& tf
) const
383 // tf is ignored for this type of tag.
386 dst
->push_back( val_
->transformed( tf
, val_
) );
391 Lang::TaggedGeometric3D::findOneTag( Kernel::EvalState
* evalState
, Lang::Symbol::KeyType key
, const Lang::Transform3D
& tf
) const
393 // tf is ignored for this type of tag.
396 Kernel::ContRef cont
= evalState
->cont_
;
397 cont
->takeValue( val_
->transformed( tf
, val_
),
405 Lang::TaggedGeometric3D::show( std::ostream
& os
) const
409 os
<< "Geometric value (3D) with the tag " << Lang::Symbol::nameFromKey( key_
).getPtr( ) ;
413 os
<< "Geometric value (3D) with unique tag." ;
418 Lang::TaggedGeometric3D::gcMark( Kernel::GCMarkedSet
& marked
)
420 const_cast< Lang::Geometric3D
* >( val_
.getPtr( ) )->gcMark( marked
);
424 Lang::TaggedDrawable3D::TaggedDrawable3D( const RefCountPtr
< const Lang::Symbol
> & key
, const RefCountPtr
< const Lang::Drawable3D
> & val
)
425 : Lang::Tagged3D( key
), val_( val
)
428 Lang::TaggedDrawable3D::TaggedDrawable3D( const Lang::Symbol::KeyType key
, const RefCountPtr
< const Lang::Drawable3D
> & val
)
429 : Lang::Tagged3D( key
), val_( val
)
432 Lang::TaggedDrawable3D::~TaggedDrawable3D( )
435 RefCountPtr
< const Lang::Drawable2D
>
436 Lang::TaggedDrawable3D::typed_to2D( const Kernel::PassedDyn
& dyn
, const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Drawable3D
> & self
) const
438 return RefCountPtr
< const Lang::Drawable2D
>( new Lang::TaggedDrawable2D( key_
, val_
->typed_to2D( dyn
, tf
, val_
) ) );
442 Lang::TaggedDrawable3D::polygonize( std::list
< RefCountPtr
< Computation::PaintedPolygon3D
> > * zBufPile
, std::list
< RefCountPtr
< Computation::StrokedLine3D
> > * linePile
, const Kernel::PassedDyn
& dyn
, const Lang::Transform3D
& tf
, const RefCountPtr
< const Lang::Drawable3D
> & self
) const
444 // Note that polygonization eats tags.
446 val_
->polygonize( zBufPile
, linePile
, dyn
, tf
, val_
);
451 Lang::TaggedDrawable3D::findTags( std::vector
< Kernel::ValueRef
> * dst
, const Kernel::PassedDyn
& dyn
, Lang::Symbol::KeyType key
, const Lang::Transform3D
& tf
) const
453 // tf is ignored for this type of tag.
456 dst
->push_back( val_
->transformed( tf
, val_
) );
461 Lang::TaggedDrawable3D::findOneTag( Kernel::EvalState
* evalState
, Lang::Symbol::KeyType key
, const Lang::Transform3D
& tf
) const
463 // tf is ignored for this type of tag.
466 Kernel::ContRef cont
= evalState
->cont_
;
467 cont
->takeValue( val_
->transformed( tf
, val_
),
475 Lang::TaggedDrawable3D::show( std::ostream
& os
) const
479 os
<< "Drawable value (3D) with the tag " << Lang::Symbol::nameFromKey( key_
).getPtr( ) ;
483 os
<< "Drawable value (3D) with unique tag." ;
488 Lang::TaggedDrawable3D::gcMark( Kernel::GCMarkedSet
& marked
)
490 const_cast< Lang::Drawable3D
* >( val_
.getPtr( ) )->gcMark( marked
);