Logo Search packages:      
Sourcecode: sailcut version File versions  Download package

sail.h

/*
 * Copyright (C) 1993-2005 Robert & Jeremy Lainé
 * See AUTHORS file for a full list of contributors.
 *
 * $Id: sail.h,v 1.43 2005/09/29 20:39:23 sailcuter Exp $
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef SAIL_H
#define SAIL_H

#include <QString>

#include "geocpp/vect_geom.h"
#include "geocpp/subspace.h"
#include "geocpp/matrix.h"
#include <vector>
#include "sailcalc.h"

enum enumPointType { LUFF, FOOT, LEECH, GAFF };
enum enumAlign {LEFT, LOW_LEFT, BOTTOM};
enum enumDevelopAlign {ALIGN_TOP,ALIGN_BOTTOM };

/*****************************************************************************

                                CPanelLabel class

*****************************************************************************/
/** This class describe a label for a panel
*/
00044 class CPanelLabel
{
public:
    CPanelLabel();
    CPanelLabel( const CPanelLabel& );
    ~CPanelLabel()
    {}
00051     ;

    /** label name of the panel */
    QString name;

    /** label text height (default : 5) */
00057     int height;

    /** label text color (default : 1) */
00060     int color;

    /** origin of the label */
00063     CPoint3d origin;

    /** direction for writing the label */
00066     CVector3d direction;

    /** function for rotating a label. */
    CPanelLabel rotate( const CPoint3d &, const CMatrix & ) const;

    /** operator to translate a label */
    CPanelLabel operator+ (const CVector3d &) const;

    /** operator to copy a label */
    CPanelLabel& operator=( const CPanelLabel &);

    friend ostream& operator<< (ostream &, const CPanelLabel &);
};


/*****************************************************************************

                               CSide class

*****************************************************************************/

/** This class describes a side of a panel
 */
00089 class CSide
{
public:
    CSide( unsigned int = 1 );
    CSide( const CSide& );
    ~CSide();

    /** the points that make up the side */
00097     vector<CPoint3d> point;

    // member functions
public:
    void fill( const CPoint3d &, const CPoint3d & );
    void fill( const CPoint3d &, const CPoint3d &, const CPoint3d & );

    /** Accessor for the number of points. */
00105     unsigned int nbpoints() const
    {
        return point.size();
    };

    /** function for rotating a side. */
    CSide rotate( const CPoint3d &, const CMatrix &) const;

    // operators
    CSide operator+ (const CVector3d &) const;
    CSide& operator= (const CSide &);
    friend ostream& operator<< (ostream &, const CSide &);
};


/** This class describes a seam of a sail.
 *
 * @see CSide
 */
00124 class CSeam : public CSide
{
public:
    /** Constructor */
00128     CSeam( unsigned int i = 1 ) : CSide( i )
    {}
00130     ;
    /** type of the left point */
    enumPointType leftPoint;
    /** type of the right point */
00134     enumPointType rightPoint;
};


/*****************************************************************************

                          Panel and Sail classes

*****************************************************************************/

/** This class holds a sail panel
 */
00146 class CPanel
{
public:
    CPanel();
    CPanel( const CPanel &p );
    ~CPanel()
    {}
00153     ;
    /** panel's label */
    CPanelLabel label;

    /** panel's left side */
00158     CSide left;
    /** panel's right side */
00160     CSide right;
    /** panel's top side */
00162     CSide top;
    /** panel's bottom side */
00164     CSide bottom;

    /** panel's cut left side */
00167     CSide cutLeft;
    /** panel's cut right side */
00169     CSide cutRight;
    /** panel's cut top side */
00171     CSide cutTop;
    /** panel's cut bottom side */
00173     CSide cutBottom;

    /** do we have hems added to the panel edges? */
00176     bool hasHems;

    // member functions
    CRect3d boundingRect() const;
    CPoint3d centroid() const; // centroid of a panel
    void addHems( const real &, const real &, const real &, const real &);
    CPanel develop(enumDevelopAlign align) const;
    real height() const;    //  height Y of a panel
    void placeLabel();   //  place a label at the center of a panel
    CPanel reframe(enumAlign align) const;
    CPanel rotate( const CPoint3d &, const CMatrix &) const;
    CPanel operator+ (const CVector3d &) const;
    CPanel& operator= (const CPanel &);

    friend ostream& operator<< (ostream &, const CPanel &);
};



/** This class holds a 3D or developed sail.
 */
00197 class CSail
{
public:
    CSail( unsigned int = 0 );
    CSail( const CSail& );
    CSail( const CPanel& );
    ~CSail();

    /** the sail's panels */
00206     vector<CPanel> panel;

    /** has the sail changed */
00209     bool changed;

    /** title of the sail */
00212     QString sailID;

protected:
    /** bounding rectangle containing the whole sail */
00216     CRect3d _boundingrect;

    // member functions
public:
    /** rectangle containing a panel. */
    CRect3d boundingRect();

    /** accessor for the number of panels. */
00224     unsigned int nbpanels() const
    {
        return panel.size();
    };

    /** function to place the labels on a displayed sail */
    void placeLabels();
    /** function to place the labels on a plotted sail */
    void plotLabels();

    /** function for rotating a panel. */
    CSail rotate( const CPoint3d &, const CMatrix & ) const;

    // operators
    CSail& operator=( const CSail &);
    CSail operator+ (const CVector3d &) const;
    friend ostream& operator<< (ostream &, const CSail &);
};


// global functions
ostream& operator<< (ostream &, const CPanel &);
ostream& operator<< (ostream &, const CSail &);
ostream& operator<< (ostream &, const CSide &);
ostream& operator<< (ostream &, const CPanelLabel &);

#endif

Generated by  Doxygen 1.6.0   Back to index