[Sketcher] Add some utility functions to Sketcher::Constraint
`involvesGeoId`, `invovesGeoIdAndPosId`, `substituteIndexAndPos`
This commit is contained in:
@@ -239,6 +239,25 @@ void Constraint::substituteIndex(int fromGeoId, int toGeoId)
|
||||
}
|
||||
}
|
||||
|
||||
void Constraint::substituteIndexAndPos(int fromGeoId,
|
||||
PointPos fromPosId,
|
||||
int toGeoId,
|
||||
PointPos toPosId)
|
||||
{
|
||||
if (this->First == fromGeoId && this->FirstPos == fromPosId) {
|
||||
this->First = toGeoId;
|
||||
this->FirstPos = toPosId;
|
||||
}
|
||||
if (this->Second == fromGeoId && this->SecondPos == fromPosId) {
|
||||
this->Second = toGeoId;
|
||||
this->SecondPos = toPosId;
|
||||
}
|
||||
if (this->Third == fromGeoId && this->ThirdPos == fromPosId) {
|
||||
this->Third = toGeoId;
|
||||
this->ThirdPos = toPosId;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Constraint::typeToString(ConstraintType type)
|
||||
{
|
||||
return type2str[type];
|
||||
|
||||
@@ -132,6 +132,21 @@ public:
|
||||
/// utility function to swap the index in First/Second/Third of the provided constraint from the
|
||||
/// fromGeoId GeoId to toGeoId
|
||||
void substituteIndex(int fromGeoId, int toGeoId);
|
||||
/// utility function to swap the index and position in First/Second/Third of the provided
|
||||
/// constraint from {fromGeoId, fromPosId} to {toGeoId, toPosId}.
|
||||
void substituteIndexAndPos(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId);
|
||||
|
||||
/// utility function to check if `geoId` is one of the geometries
|
||||
bool involvesGeoId(int geoId) const
|
||||
{
|
||||
return First == geoId || Second == geoId || Third == geoId;
|
||||
}
|
||||
/// utility function to check if (`geoId`, `posId`) is one of the points/curves
|
||||
bool involvesGeoIdAndPosId(int geoId, PointPos posId) const
|
||||
{
|
||||
return (First == geoId && FirstPos == posId) || (Second == geoId && SecondPos == posId)
|
||||
|| (Third == geoId && ThirdPos == posId);
|
||||
}
|
||||
|
||||
std::string typeToString() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user