/**************************************************************************** Copyright (C) 2010-2021 the Office National des Forêts (ONF), France All rights reserved. Contact : alexandre.piboule@onf.fr Developers : Michael Krebbs (Independant) Alexandre PIBOULE (ONF) This file is part of PluginGenerate library. PluginGenerate is free library: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. PluginGenerate 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 Lesser General Public License along with PluginGenerate. If not, see . *****************************************************************************/ #include "gen_stepgeneratecylindermesh.h" #include "ct_mesh/ct_mesh.h" #include "ct_itemdrawable/ct_standarditemgroup.h" // Alias for indexing out models GEN_StepGenerateCylinderMesh::GEN_StepGenerateCylinderMesh() : SuperClass() { _height = 1; _radius = 1; _slices = 30; _x = _y = _z = 0; } QString GEN_StepGenerateCylinderMesh::description() const { return tr("Créer un Maillage Cylindrique"); } CT_VirtualAbstractStep* GEN_StepGenerateCylinderMesh::createNewInstance() const { return new GEN_StepGenerateCylinderMesh(); } //////////////////// PROTECTED METHODS ////////////////// void GEN_StepGenerateCylinderMesh::declareInputModels(CT_StepInModelStructureManager& manager) { manager.setNotNeedInputResult(); } void GEN_StepGenerateCylinderMesh::declareOutputModels(CT_StepOutModelStructureManager& manager) { manager.addResult(m_hOutResult, tr("Generated Mesh")); manager.setRootGroup(m_hOutResult, m_hOutRootGroup); manager.addItem(m_hOutRootGroup, m_hOutMesh, tr("Generated Mesh")); } void GEN_StepGenerateCylinderMesh::fillPostInputConfigurationDialog(CT_StepConfigurableDialog* postInputConfigDialog) { postInputConfigDialog->addDouble(tr("Height"), "", 0.0001, std::numeric_limits::max(), 4, _height); postInputConfigDialog->addDouble(tr("Radius"), "", 0.0001, std::numeric_limits::max(), 4, _radius); postInputConfigDialog->addInt(tr("Slices"), "", 4, 99999, _slices); postInputConfigDialog->addDouble("X", "", -std::numeric_limits::max(), std::numeric_limits::max(), 4, _x); postInputConfigDialog->addDouble("Y", "", -std::numeric_limits::max(), std::numeric_limits::max(), 4, _y); postInputConfigDialog->addDouble("Z", "", -std::numeric_limits::max(), std::numeric_limits::max(), 4, _z); } void GEN_StepGenerateCylinderMesh::compute() { for(CT_ResultGroup* result : m_hOutResult.iterateOutputs()) { CT_StandardItemGroup* rootGroup = m_hOutRootGroup.createInstance(); result->addRootGroup(m_hOutRootGroup, rootGroup); CT_Mesh *mesh = new CT_Mesh(); mesh->createCylinder(_radius, _height, _slices, _x, _y, _z); CT_MeshModel* itemOut_scene = new CT_MeshModel(mesh); itemOut_scene->setBoundingBox(_x, (-_radius)+_y, (-_radius)+_z, _height+_x, _radius+_y, _radius+_z); rootGroup->addSingularItem(m_hOutMesh, itemOut_scene); } }