1 /*
2 *	Copyright (C) 2008-2012 Thorsten Liebig (Thorsten.Liebig@gmx.de)
3 *
4 *	This program is free software: you can redistribute it and/or modify
5 *	it under the terms of the GNU Lesser General Public License as published
6 *	by the Free Software Foundation, either version 3 of the License, or
7 *	(at your option) any later version.
8 *
9 *	This program is distributed in the hope that it will be useful,
10 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *	GNU Lesser General Public License for more details.
13 *
14 *	You should have received a copy of the GNU Lesser General Public License
15 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #pragma once
19 
20 #include "CSPrimitives.h"
21 
22 //! Box Primitive (Cube)
23 /*!
24  This is a cube primitive defined by its start-, end-coordinates.
25  */
26 class CSXCAD_EXPORT CSPrimBox : public CSPrimitives
27 {
28 public:
29 	CSPrimBox(ParameterSet* paraSet, CSProperties* prop);
30 	CSPrimBox(CSPrimBox* primBox, CSProperties *prop=NULL);
31 	CSPrimBox(unsigned int ID, ParameterSet* paraSet, CSProperties* prop);
32 	virtual ~CSPrimBox();
33 
34 	virtual CSPrimitives* GetCopy(CSProperties *prop=NULL) {return new CSPrimBox(this,prop);}
35 
SetCoord(int index,double val)36 	void SetCoord(int index, double val) {if ((index>=0) && (index<6)) m_Coords[index%2].SetValue(index/2,val);}
SetCoord(int index,const char * val)37 	void SetCoord(int index, const char* val) {if ((index>=0) && (index<6)) m_Coords[index%2].SetValue(index/2,val);}
SetCoord(int index,std::string val)38 	void SetCoord(int index, std::string val) {if ((index>=0) && (index<6)) m_Coords[index%2].SetValue(index/2,val);}
39 
GetCoord(int index)40 	double GetCoord(int index) {if ((index>=0) && (index<6)) return m_Coords[index%2].GetValue(index/2); else return 0;}
GetCoordPS(int index)41 	ParameterScalar* GetCoordPS(int index) {if ((index>=0) && (index<6)) return m_Coords[index%2].GetCoordPS(index/2); else return NULL;}
42 
GetStartCoord()43 	ParameterCoord* GetStartCoord() {return &m_Coords[0];}
GetStopCoord()44 	ParameterCoord* GetStopCoord() {return &m_Coords[1];}
45 
46 	virtual bool GetBoundBox(double dBoundBox[6], bool PreserveOrientation=false);
47 	virtual bool IsInside(const double* Coord, double tol=0);
48 
49 	virtual bool Update(std::string *ErrStr=NULL);
50 	virtual bool Write2XML(TiXmlElement &elem, bool parameterised=true);
51 	virtual bool ReadFromXML(TiXmlNode &root);
52 
53 	virtual void ShowPrimitiveStatus(std::ostream& stream);
54 
55 protected:
56 	//start and stop coords defining the box
57 	ParameterCoord m_Coords[2];
58 };
59 
60