/**************************************************************************** Copyright (C) 2010-2012 the Office National des Forêts (ONF), France All rights reserved. Contact : alexandre.piboule@onf.fr Developers : Alexandre PIBOULE (ONF) This file is part of PluginONF library. PluginONF 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. PluginONF 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 PluginONF. If not, see . *****************************************************************************/ #include "onf_steprefpointfromarccenter.h" #include "ct_itemdrawable/tools/pointclustertools/ct_polylinesalgorithms.h" ONF_StepRefPointFromArcCenter::ONF_StepRefPointFromArcCenter() : SuperClass() { } QString ONF_StepRefPointFromArcCenter::description() const { return tr("Créer des points de référence à partir d'arcs"); } QString ONF_StepRefPointFromArcCenter::detailledDescription() const { return tr(""); } QString ONF_StepRefPointFromArcCenter::inputDescription() const { return SuperClass::inputDescription() + tr("

"); } QString ONF_StepRefPointFromArcCenter::outputDescription() const { return SuperClass::outputDescription() + tr("

"); } QString ONF_StepRefPointFromArcCenter::detailsDescription() const { return tr(""); } CT_VirtualAbstractStep* ONF_StepRefPointFromArcCenter::createNewInstance() const { // cree une copie de cette etape return new ONF_StepRefPointFromArcCenter(); } //////////////////// PROTECTED ////////////////// void ONF_StepRefPointFromArcCenter::declareInputModels(CT_StepInModelStructureManager& manager) { manager.addResult(_inResult, tr("Polyligne(s)")); manager.setZeroOrMoreRootGroup(_inResult, _inZeroOrMoreRootGroup); manager.addGroup(_inZeroOrMoreRootGroup, _inGroup); manager.addItem(_inGroup, _inPolyline, tr("Polyligne")); } void ONF_StepRefPointFromArcCenter::declareOutputModels(CT_StepOutModelStructureManager& manager) { manager.addResultCopy(_inResult); manager.addItem(_inGroup, _outBarycenter, tr("Barycentre")); } void ONF_StepRefPointFromArcCenter::compute() { for (CT_StandardItemGroup* group : _inGroup.iterateOutputs(_inResult)) { if (isStopped()) {return;} const CT_PointCluster* item = group->singularItem(_inPolyline); if(item != nullptr) { double sagitta = 0; double chord = 0; double radius = 0; Eigen::Vector2d center = CT_PolylinesAlgorithms::compute2DArcData(item, sagitta, chord, radius); if (radius > chord) { radius = chord; } // et on ajoute un referencePoint group->addSingularItem(_outBarycenter, new CT_ReferencePoint(center.x(), center.y(), item->centerZ(), radius)); } } setProgress(100); }