leocad/common/lc_synth.h

57 lines
1.5 KiB
C
Raw Normal View History

#pragma once
2016-10-05 23:28:52 +02:00
#include "lc_math.h"
#include "piece.h"
class lcLibraryMeshData;
class lcSynthInfo
{
public:
Synthesis of Technic Universal Joints (#456) * Split synth info initialzation by type. We are going to remove the type enumeration and use a class hierarchy instead. This preparation will then be helpful. * Make Add...Parts() overrides of a virtual AddPart() function. Since we have a class hierarchy for the different synthesized pieces, we can now turn a case distinction into a virtual function call. * Move initialization based on type to derived class constructors. Move initialization of end transformations of flexible parts into class lcSynthInfoCurved. * Make GetDefaultControlPoints() virtual with overrides. * Remove obsolete enum lcSynthType. We have replaced its purpose by derived classes by now. * Initialize shock absorbers' spring part ID early. This removes the awkward early return that is needed in the if-else cascade. * Split lcSynthInfo into derived classes for curved and straight pieces. * Only curved parts have varying sections, start, middle, and end properties. Move the properties from the base class to the derived class that needs them. * Use derived classes to mark synthesized objects of different kinds. We will extend the derived classes in the upcoming commits. * PieceInfo is only needed to synthesize some hoses and shock absorbers. * Initialize edge part IDs of flexible hoses early. This removes another case distinction in AddParts(). * Verify the number of control points loaded from a model file. * Synthesize Technic universal joints. The direction of one end can be changed so that it points to the control point. * Technic universal joints need only the position of the control point. * Synthesize legacy universal joints.
2020-03-30 21:17:08 +02:00
explicit lcSynthInfo(float Length);
virtual ~lcSynthInfo() = default;
2016-10-05 23:28:52 +02:00
2020-05-04 00:39:39 +02:00
lcSynthInfo(const lcSynthInfo&) = delete;
lcSynthInfo(lcSynthInfo&&) = delete;
lcSynthInfo& operator=(const lcSynthInfo&) = delete;
lcSynthInfo& operator=(lcSynthInfo&&) = delete;
2016-10-05 23:28:52 +02:00
bool CanAddControlPoints() const
{
return mCurve;
}
bool IsCurve() const
{
return mCurve;
}
Synthesis of Technic Universal Joints (#456) * Split synth info initialzation by type. We are going to remove the type enumeration and use a class hierarchy instead. This preparation will then be helpful. * Make Add...Parts() overrides of a virtual AddPart() function. Since we have a class hierarchy for the different synthesized pieces, we can now turn a case distinction into a virtual function call. * Move initialization based on type to derived class constructors. Move initialization of end transformations of flexible parts into class lcSynthInfoCurved. * Make GetDefaultControlPoints() virtual with overrides. * Remove obsolete enum lcSynthType. We have replaced its purpose by derived classes by now. * Initialize shock absorbers' spring part ID early. This removes the awkward early return that is needed in the if-else cascade. * Split lcSynthInfo into derived classes for curved and straight pieces. * Only curved parts have varying sections, start, middle, and end properties. Move the properties from the base class to the derived class that needs them. * Use derived classes to mark synthesized objects of different kinds. We will extend the derived classes in the upcoming commits. * PieceInfo is only needed to synthesize some hoses and shock absorbers. * Initialize edge part IDs of flexible hoses early. This removes another case distinction in AddParts(). * Verify the number of control points loaded from a model file. * Synthesize Technic universal joints. The direction of one end can be changed so that it points to the control point. * Technic universal joints need only the position of the control point. * Synthesize legacy universal joints.
2020-03-30 21:17:08 +02:00
bool IsUnidirectional() const
{
return mUnidirectional;
}
bool IsNondirectional() const
{
return mNondirectional;
}
2024-05-12 21:45:15 +02:00
virtual void GetDefaultControlPoints(std::vector<lcPieceControlPoint>& ControlPoints) const = 0;
virtual void VerifyControlPoints(std::vector<lcPieceControlPoint>& ControlPoints) const = 0;
int InsertControlPoint(std::vector<lcPieceControlPoint>& ControlPoints, const lcVector3& Start, const lcVector3& End) const;
lcMesh* CreateMesh(const std::vector<lcPieceControlPoint>& ControlPoints) const;
2016-10-05 23:28:52 +02:00
protected:
2024-05-12 21:45:15 +02:00
using SectionCallbackFunc = std::function<void(const lcVector3& CurvePoint, quint32 SegmentIndex, float t)>;
2024-06-09 21:33:02 +02:00
virtual void CalculateSections(const std::vector<lcPieceControlPoint>& ControlPoints, std::vector<lcMatrix44>& Sections, SectionCallbackFunc SectionCallback) const = 0;
virtual void AddParts(lcMemFile& File, lcLibraryMeshData& MeshData, const std::vector<lcMatrix44>& Sections) const = 0;
2016-10-05 23:28:52 +02:00
Synthesis of Technic Universal Joints (#456) * Split synth info initialzation by type. We are going to remove the type enumeration and use a class hierarchy instead. This preparation will then be helpful. * Make Add...Parts() overrides of a virtual AddPart() function. Since we have a class hierarchy for the different synthesized pieces, we can now turn a case distinction into a virtual function call. * Move initialization based on type to derived class constructors. Move initialization of end transformations of flexible parts into class lcSynthInfoCurved. * Make GetDefaultControlPoints() virtual with overrides. * Remove obsolete enum lcSynthType. We have replaced its purpose by derived classes by now. * Initialize shock absorbers' spring part ID early. This removes the awkward early return that is needed in the if-else cascade. * Split lcSynthInfo into derived classes for curved and straight pieces. * Only curved parts have varying sections, start, middle, and end properties. Move the properties from the base class to the derived class that needs them. * Use derived classes to mark synthesized objects of different kinds. We will extend the derived classes in the upcoming commits. * PieceInfo is only needed to synthesize some hoses and shock absorbers. * Initialize edge part IDs of flexible hoses early. This removes another case distinction in AddParts(). * Verify the number of control points loaded from a model file. * Synthesize Technic universal joints. The direction of one end can be changed so that it points to the control point. * Technic universal joints need only the position of the control point. * Synthesize legacy universal joints.
2020-03-30 21:17:08 +02:00
bool mCurve = false;
bool mUnidirectional = false;
bool mNondirectional = false;
2016-10-05 23:28:52 +02:00
float mLength;
};
void lcSynthInit();