|
| 1 | +/****************************************************************************** |
| 2 | +* SOFA, Simulation Open-Framework Architecture * |
| 3 | +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * |
| 4 | +* * |
| 5 | +* This program is free software; you can redistribute it and/or modify it * |
| 6 | +* under the terms of the GNU Lesser General Public License as published by * |
| 7 | +* the Free Software Foundation; either version 2.1 of the License, or (at * |
| 8 | +* your option) any later version. * |
| 9 | +* * |
| 10 | +* This program is distributed in the hope that it will be useful, but WITHOUT * |
| 11 | +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * |
| 12 | +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * |
| 13 | +* for more details. * |
| 14 | +* * |
| 15 | +* You should have received a copy of the GNU Lesser General Public License * |
| 16 | +* along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 | +******************************************************************************* |
| 18 | +* Authors: The SOFA Team and external contributors (see Authors.txt) * |
| 19 | +* * |
| 20 | +* Contact information: contact@sofa-framework.org * |
| 21 | +******************************************************************************/ |
| 22 | +#pragma once |
| 23 | +#include <sofa/component/collision/detection/algorithm/config.h> |
| 24 | + |
| 25 | +#include <sofa/core/objectmodel/BaseObject.h> |
| 26 | + |
| 27 | +#include <set> |
| 28 | +#include <string> |
| 29 | + |
| 30 | +namespace sofa::core |
| 31 | +{ |
| 32 | +class CollisionModel; |
| 33 | +} |
| 34 | + |
| 35 | +namespace sofa::component::collision::detection::algorithm |
| 36 | +{ |
| 37 | + |
| 38 | +/** |
| 39 | + * @brief Abstract base class defining the interface for sub-collision pipelines. |
| 40 | + * |
| 41 | + * This base class is designed to be used with CompositeCollisionPipeline, which |
| 42 | + * aggregates multiple sub-pipelines and can execute them in parallel. |
| 43 | + * |
| 44 | + * @see SubCollisionPipeline for a concrete implementation |
| 45 | + * @see CompositeCollisionPipeline for the aggregator that manages sub-pipelines |
| 46 | + */ |
| 47 | +class SOFA_COMPONENT_COLLISION_DETECTION_ALGORITHM_API BaseSubCollisionPipeline : public sofa::core::objectmodel::BaseObject |
| 48 | +{ |
| 49 | +public: |
| 50 | + SOFA_ABSTRACT_CLASS(BaseSubCollisionPipeline, sofa::core::objectmodel::BaseObject); |
| 51 | + |
| 52 | +protected: |
| 53 | + BaseSubCollisionPipeline(); |
| 54 | + |
| 55 | + /// @brief Called during initialization. Derived classes must implement validation and setup logic. |
| 56 | + virtual void doInit() = 0; |
| 57 | + |
| 58 | + /// @brief Called after all objects are initialized. Default implementation is empty. |
| 59 | + virtual void doBwdInit(); |
| 60 | + |
| 61 | + /// @brief Called to handle simulation events. Derived classes must implement event processing. |
| 62 | + virtual void doHandleEvent(sofa::core::objectmodel::Event* e) = 0; |
| 63 | + |
| 64 | + /// @brief Called during rendering. Default implementation is empty. |
| 65 | + virtual void doDraw(const core::visual::VisualParams* vparams); |
| 66 | + |
| 67 | +public: |
| 68 | + ///@{ |
| 69 | + /// @name Collision Pipeline Interface |
| 70 | + /// These methods define the three-phase collision workflow that derived classes must implement. |
| 71 | + |
| 72 | + /// @brief Clears collision state from the previous time step (contacts, responses). |
| 73 | + virtual void computeCollisionReset() = 0; |
| 74 | + |
| 75 | + /// @brief Performs collision detection (bounding tree, broad phase, narrow phase). |
| 76 | + virtual void computeCollisionDetection() = 0; |
| 77 | + |
| 78 | + /// @brief Creates collision responses based on detected contacts. |
| 79 | + virtual void computeCollisionResponse() = 0; |
| 80 | + |
| 81 | + ///@} |
| 82 | + |
| 83 | + /// @brief Returns the list of collision models handled by this sub-pipeline. |
| 84 | + virtual std::vector<sofa::core::CollisionModel*> getCollisionModels() = 0; |
| 85 | + |
| 86 | + /// @brief Initializes the component. Marked final to enforce Template Method pattern. |
| 87 | + void init() override final; |
| 88 | + |
| 89 | + /// @brief Renders debug visualization. Marked final to enforce Template Method pattern. |
| 90 | + void draw(const core::visual::VisualParams* vparams) override final; |
| 91 | + |
| 92 | + /// @brief Processes simulation events. Marked final to enforce Template Method pattern. |
| 93 | + void handleEvent(sofa::core::objectmodel::Event* e) override final; |
| 94 | + |
| 95 | + /// @brief Returns all available contact response types registered in the Contact factory. |
| 96 | + static std::set< std::string > getResponseList(); |
| 97 | +}; |
| 98 | + |
| 99 | +} // namespace sofa::component::collision::detection::algorithm |
0 commit comments