ComplexGeoData.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2002     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 
00026 #ifndef _PreComp_
00027 # include <cstdlib>
00028 #endif
00029 
00030 
00031 #include "ComplexGeoData.h"
00032 
00033 using namespace Data;
00034 
00035 TYPESYSTEM_SOURCE_ABSTRACT(Data::Segment , Base::BaseClass);
00036 
00037 
00038 TYPESYSTEM_SOURCE_ABSTRACT(Data::ComplexGeoData , Base::Persistence);
00039 
00040 
00041 ComplexGeoData::ComplexGeoData(void)
00042 {
00043 }
00044 
00045 ComplexGeoData::~ComplexGeoData(void)
00046 {
00047 }
00048 
00049 Data::Segment* ComplexGeoData::getSubElementByName(const char* name) const
00050 {
00051     int index = 0;
00052     std::string element(name);
00053     std::string::size_type pos = element.find_first_of("0123456789");
00054     if (pos != std::string::npos) {
00055         index = std::atoi(element.substr(pos).c_str());
00056         element = element.substr(0,pos);
00057     }
00058 
00059     return getSubElement(element.c_str(),index);
00060 }
00061 
00062 void ComplexGeoData::applyTransform(const Base::Matrix4D& rclTrf)
00063 {
00064     setTransform(rclTrf * getTransform());
00065 }
00066 
00067 void ComplexGeoData::applyTranslation(const Base::Vector3d& mov)
00068 {
00069     Base::Matrix4D mat;
00070     mat.move(mov);
00071     setTransform(mat * getTransform());
00072 }
00073 
00074 void ComplexGeoData::applyRotation(const Base::Rotation& rot)
00075 {
00076     Base::Matrix4D mat;
00077     rot.getValue(mat);
00078     setTransform(mat * getTransform());
00079 }
00080 
00081 void ComplexGeoData::setPlacement(const Base::Placement& rclPlacement)
00082 {
00083     setTransform(rclPlacement.toMatrix());
00084 }
00085 
00086 Base::Placement ComplexGeoData::getPlacement() const
00087 {
00088     Base::Matrix4D mat = getTransform();
00089 
00090     return Base::Placement(Base::Vector3d(mat[0][3],
00091                                           mat[1][3],
00092                                           mat[2][3]),
00093                            Base::Rotation(mat));
00094 }

Generated on Wed Nov 23 19:00:03 2011 for FreeCAD by  doxygen 1.6.1