void Face_makeBrush( Face& face, const Brush& brush, brush_vector_t& out, float offset ){
if ( face.contributes() ) {
out.push_back( new Brush( brush ) );
- Face* newFace = out.back()->addFace( face );
+ std::shared_ptr<Face> newFace = out.back()->addFace( face );
if ( newFace != 0 ) {
newFace->flipWinding();
newFace->getPlane().offset( offset );
face.getPlane().offset( offset );
out.push_back( new Brush( brush ) );
face.getPlane().offset( -offset );
- Face* newFace = out.back()->addFace( face );
+ std::shared_ptr<Face> newFace = out.back()->addFace( face );
if ( newFace != 0 ) {
newFace->flipWinding();
newFace->planeChanged();
return Dereference<Functor>( functor );
}
-typedef Face* FacePointer;
-const FacePointer c_nullFacePointer = 0;
-
-template<typename Predicate>
-Face* Brush_findIf( const Brush& brush, const Predicate& predicate ){
- Brush::const_iterator i = std::find_if( brush.begin(), brush.end(), makeDereference( predicate ) );
- return i == brush.end() ? c_nullFacePointer : *i; // uses c_nullFacePointer instead of 0 because otherwise gcc 4.1 attempts conversion to int
-}
-
template<typename Caller>
class BindArguments1
{
/// \li flipped && brush is FRONT or ON
bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){
brush.evaluateBRep();
-#if 1
for ( Brush::const_iterator i( brush.begin() ); i != brush.end(); ++i )
{
if ( Face_testPlane( *( *i ), plane, flipped ) ) {
}
}
return true;
-#else
- return Brush_findIf( brush, bindArguments( FaceTestPlane(), makeReference( plane ), flipped ) ) == 0;
-#endif
}
brushsplit_t Brush_classifyPlane( const Brush& brush, const Plane3& plane ){
fragments.reserve( other.size() );
Brush back( brush );
- for ( Brush::const_iterator i( other.begin() ); i != other.end(); ++i )
+ for ( const std::shared_ptr<Face>& b : other )
{
- if ( ( *i )->contributes() ) {
- brushsplit_t split = Brush_classifyPlane( back, ( *i )->plane3() );
+ if ( b->contributes() ) {
+ brushsplit_t split = Brush_classifyPlane( back, b->plane3() );
if ( split.counts[ePlaneFront] != 0
&& split.counts[ePlaneBack] != 0 ) {
fragments.push_back( new Brush( back ) );
- Face* newFace = fragments.back()->addFace( *( *i ) );
- if ( newFace != 0 ) {
+ std::shared_ptr<Face> newFace = fragments.back()->addFace( *b );
+ if ( newFace != nullptr ) {
newFace->flipWinding();
}
- back.addFace( *( *i ) );
+ back.addFace( *b );
}
else if ( split.counts[ePlaneBack] == 0 ) {
- for ( brush_vector_t::iterator i = fragments.begin(); i != fragments.end(); ++i )
- {
- delete( *i );
+ for ( Brush *i : fragments ) {
+ delete( i );
}
+ fragments.clear();
return false;
}
}
NodeSmartReference node( ( new BrushNode() )->node() );
Brush* fragment = Node_getBrush( node );
fragment->copy( *brush );
- Face* newFace = fragment->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection );
+ std::shared_ptr<Face> newFace =
+ fragment->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection );
if ( newFace != 0 && m_split != eFront ) {
newFace->flipWinding();
}
}
}
- Face* newFace = brush->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection );
+ std::shared_ptr<Face> newFace = brush->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection );
if ( newFace != 0 && m_split == eFront ) {
newFace->flipWinding();
}