- if (myEntities[aPos].type == SLVS_E_LINE_SEGMENT) {
- if (aNbFixed == 2)
- return true;
- else if (aNbFixed == 0 || !theAccurate)
- return false;
- // Additional check (the line may be fixed if it is used by different constraints):
- // 1. The line is used in Equal constraint, another entity is fixed and there is a fixed point on line
- aList = getConstraintsByType(SLVS_C_PT_ON_LINE);
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if (anIt->entityA == theEntityID && isPointFixed(anIt->ptA, aTempID))
- break;
- if (anIt != aList.end()) {
- aList = getConstraintsByType(SLVS_C_EQUAL_LENGTH_LINES);
- aList.splice(aList.end(), getConstraintsByType(SLVS_C_EQUAL_LINE_ARC_LEN));
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if (anIt->entityA == theEntityID || anIt->entityB == theEntityID) {
- Slvs_hEntity anOther = anIt->entityA == theEntityID ? anIt->entityB : anIt->entityA;
- if (isEntityFixed(anOther, false))
- return true;
- }
- }
- // 2. The line is used in Parallel/Perpendicular and Length constraints
- aList = getConstraintsByType(SLVS_C_PARALLEL);
- aList.splice(aList.end(), getConstraintsByType(SLVS_C_PERPENDICULAR));
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if (anIt->entityA == theEntityID || anIt->entityB == theEntityID) {
- Slvs_hEntity anOther = anIt->entityA == theEntityID ? anIt->entityB : anIt->entityA;
- if (isEntityFixed(anOther, false))
- break;
- }
- if (anIt != aList.end()) {
- aList = getConstraintsByType(SLVS_C_PT_PT_DISTANCE);
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if ((anIt->ptA == myEntities[aPos].point[0] && anIt->ptB == myEntities[aPos].point[1]) ||
- (anIt->ptA == myEntities[aPos].point[1] && anIt->ptB == myEntities[aPos].point[0]))
- return true;
- }
- // 3. Another verifiers ...
- } else if (myEntities[aPos].type == SLVS_E_CIRCLE) {
- if (aNbFixed == 0)
- return false;
- // Search for Diameter constraint
- aList = getConstraintsByType(SLVS_C_DIAMETER);
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if (anIt->entityA == theEntityID)
- return true;
- if (!theAccurate)
- return false;
- // Additional check (the circle may be fixed if it is used by different constraints):
- // 1. The circle is used in Equal constraint and another entity is fixed
- aList = getConstraintsByType(SLVS_C_EQUAL_RADIUS);
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if (anIt->entityA == theEntityID || anIt->entityB == theEntityID) {
- Slvs_hEntity anOther = anIt->entityA == theEntityID ? anIt->entityB : anIt->entityA;
- if (isEntityFixed(anOther, false))
- return true;
- }
- // 2. Another verifiers ...
- } else if (myEntities[aPos].type == SLVS_E_ARC_OF_CIRCLE) {
- if (aNbFixed > 2)
- return true;
- else if (aNbFixed <= 1)
- return false;
- // Search for Diameter constraint
- aList = getConstraintsByType(SLVS_C_DIAMETER);
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if (anIt->entityA == theEntityID)
- return true;
- if (!theAccurate)
- return false;
- // Additional check (the arc may be fixed if it is used by different constraints):
- // 1. The arc is used in Equal constraint and another entity is fixed
- aList = getConstraintsByType(SLVS_C_EQUAL_RADIUS);
- aList.splice(aList.end(), getConstraintsByType(SLVS_C_EQUAL_LINE_ARC_LEN));
- for (anIt = aList.begin(); anIt != aList.end(); anIt++)
- if (anIt->entityA == theEntityID || anIt->entityB == theEntityID) {
- Slvs_hEntity anOther = anIt->entityA == theEntityID ? anIt->entityB : anIt->entityA;
- if (isEntityFixed(anOther, false))
- return true;
- }
- // 2. Another verifiers ...
- }