File indexing completed on 2024-05-05 03:41:16
0001 /************************************************************************************* 0002 * Copyright (C) 2010-2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #include "private/abstractsurface.h" 0020 // #include "private/surfacefactory.h" 0021 #include "private/functiongraphfactory.h" 0022 0023 #include <analitza/value.h> 0024 #include <analitza/vector.h> 0025 0026 using namespace Analitza; 0027 0028 class ParamSurf : public AbstractSurface 0029 { 0030 public: 0031 CONSTRUCTORS(ParamSurf) 0032 TYPE_NAME(QT_TRANSLATE_NOOP("Function type", "Parametric Surface")) 0033 EXPRESSION_TYPE(Analitza::ExpressionType(Analitza::ExpressionType::Lambda).addParameter( 0034 Analitza::ExpressionType(Analitza::ExpressionType::Value)).addParameter( 0035 Analitza::ExpressionType(Analitza::ExpressionType::Value)).addParameter( 0036 Analitza::ExpressionType(Analitza::ExpressionType::Vector, Analitza::ExpressionType( 0037 Analitza::ExpressionType::Value), 3))) 0038 COORDDINATE_SYSTEM(Cartesian) 0039 PARAMETERS(QStringList(QStringLiteral("u")) << QStringLiteral("v")) 0040 ICON_NAME(QStringLiteral("draw-donut")) 0041 EXAMPLES(QStringList()) 0042 0043 //Own 0044 0045 QVector3D fromParametricArgs(double u, double v) override; 0046 void update(const QVector3D& oppositecorner1, const QVector3D& oppositecorner2) override; 0047 }; 0048 0049 QVector3D ParamSurf::fromParametricArgs(double u, double v) 0050 { 0051 arg(QStringLiteral("u"))->setValue(u); 0052 arg(QStringLiteral("v"))->setValue(v); 0053 0054 Analitza::Expression res = analyzer->calculateLambda(); 0055 Analitza::Cn x=res.elementAt(0).toReal(); 0056 Analitza::Cn y=res.elementAt(1).toReal(); 0057 Analitza::Cn z=res.elementAt(2).toReal(); 0058 0059 return QVector3D(x.value(), y.value(), z.value()); 0060 } 0061 0062 void ParamSurf::update(const QVector3D & /*oppositecorner1*/, const QVector3D & /*oppositecorner2*/) 0063 { 0064 buildParametricSurface(); 0065 } 0066 0067 0068 REGISTER_SURFACE(ParamSurf)