Skip to content

Commit

Permalink
added extend,trim algorithm for dim
Browse files Browse the repository at this point in the history
  • Loading branch information
하승호 authored and 하승호 committed Oct 23, 2019
1 parent 218c2f5 commit ec7a0d7
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 0 deletions.
114 changes: 114 additions & 0 deletions ShCAD/ShCAD/Entity/Private/ShExtender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#include "Entity\Leaf\ShCircle.h"
#include "Entity\Leaf\ShArc.h"
#include "Base\ShMath.h"
#include "Entity\Composite\Dim\ShDimLinear.h"
#include "Entity\Composite\Dim\ShDimAligned.h"
#include "Entity\Composite\Dim\ShDimRadius.h"
#include "Entity\Composite\Dim\ShDimDiameter.h"
#include "Entity\Composite\Dim\ShDimArcLength.h"
#include "Entity\Composite\Dim\ShDimAngular.h"


ShEntityPartToExtendFinder::ShEntityPartToExtendFinder(ShEntityPartToExtend &entityPartToExtend, ShPoint3d &pointToExtend, const ShPoint3d &clickPoint)
Expand Down Expand Up @@ -282,6 +288,60 @@ void ShLineExtensionPointFinder::visit(ShArc *arc) {
}
}

void ShLineExtensionPointFinder::visit(ShDimLinear *dimLinear) {

ShLineExtensionPointFinder visitor(this->extensionPointList, this->lineToExtend, this->entityPartToExtend);

auto itr = dimLinear->begin();
for (itr; itr != dimLinear->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineExtensionPointFinder::visit(ShDimAligned *dimAligned) {

ShLineExtensionPointFinder visitor(this->extensionPointList, this->lineToExtend, this->entityPartToExtend);

auto itr = dimAligned->begin();
for (itr; itr != dimAligned->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineExtensionPointFinder::visit(ShDimRadius *dimRadius) {

ShLineExtensionPointFinder visitor(this->extensionPointList, this->lineToExtend, this->entityPartToExtend);

auto itr = dimRadius->begin();
for (itr; itr != dimRadius->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineExtensionPointFinder::visit(ShDimDiameter *dimDiameter) {

ShLineExtensionPointFinder visitor(this->extensionPointList, this->lineToExtend, this->entityPartToExtend);

auto itr = dimDiameter->begin();
for (itr; itr != dimDiameter->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineExtensionPointFinder::visit(ShDimArcLength *dimArcLength) {

ShLineExtensionPointFinder visitor(this->extensionPointList, this->lineToExtend, this->entityPartToExtend);

auto itr = dimArcLength->begin();
for (itr; itr != dimArcLength->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineExtensionPointFinder::visit(ShDimAngular *dimAngular) {

ShLineExtensionPointFinder visitor(this->extensionPointList, this->lineToExtend, this->entityPartToExtend);

auto itr = dimAngular->begin();
for (itr; itr != dimAngular->end(); ++itr)
(*itr)->accept(&visitor);
}

bool ShLineExtensionPointFinder::checkPossibleToExtend(ShLine *lineToExtend, ShEntityPartToExtend entityPartToExtend, const ShPoint3d &extensionPoint) {

ShLineData data = lineToExtend->getData();
Expand Down Expand Up @@ -514,6 +574,60 @@ void ShArcExtensionPointFinder::visit(ShArc *arc) {
}
}

void ShArcExtensionPointFinder::visit(ShDimLinear *dimLinear) {

ShArcExtensionPointFinder visitor(this->extensionPointList, this->arcToExtend, this->entityPartToExtend);

auto itr = dimLinear->begin();
for (itr; itr != dimLinear->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcExtensionPointFinder::visit(ShDimAligned *dimAligned) {

ShArcExtensionPointFinder visitor(this->extensionPointList, this->arcToExtend, this->entityPartToExtend);

auto itr = dimAligned->begin();
for (itr; itr != dimAligned->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcExtensionPointFinder::visit(ShDimRadius *dimRadius) {

ShArcExtensionPointFinder visitor(this->extensionPointList, this->arcToExtend, this->entityPartToExtend);

auto itr = dimRadius->begin();
for (itr; itr != dimRadius->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcExtensionPointFinder::visit(ShDimDiameter *dimDiameter) {

ShArcExtensionPointFinder visitor(this->extensionPointList, this->arcToExtend, this->entityPartToExtend);

auto itr = dimDiameter->begin();
for (itr; itr != dimDiameter->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcExtensionPointFinder::visit(ShDimArcLength *dimArcLength) {

ShArcExtensionPointFinder visitor(this->extensionPointList, this->arcToExtend, this->entityPartToExtend);

auto itr = dimArcLength->begin();
for (itr; itr != dimArcLength->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcExtensionPointFinder::visit(ShDimAngular *dimAngular) {

ShArcExtensionPointFinder visitor(this->extensionPointList, this->arcToExtend, this->entityPartToExtend);

auto itr = dimAngular->begin();
for (itr; itr != dimAngular->end(); ++itr)
(*itr)->accept(&visitor);
}

bool ShArcExtensionPointFinder::checkPossibleToExtend(ShArc *arcToExtend, ShEntityPartToExtend entityPartToExtend, const ShPoint3d &extensionPoint) {

ShArcData data = arcToExtend->getData();
Expand Down
12 changes: 12 additions & 0 deletions ShCAD/ShCAD/Entity/Private/ShExtender.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ class ShLineExtensionPointFinder : public ShExtensionPointFinder {
virtual void visit(ShLine *line);
virtual void visit(ShCircle *circle);
virtual void visit(ShArc *arc);
virtual void visit(ShDimLinear *dimLinear);
virtual void visit(ShDimAligned *dimAligned);
virtual void visit(ShDimRadius *dimRadius);
virtual void visit(ShDimDiameter *dimDiameter);
virtual void visit(ShDimArcLength *dimArcLength);
virtual void visit(ShDimAngular *dimAngular);

bool checkPossibleToExtend(ShLine *lineToExtend, ShEntityPartToExtend entityPartToExtend, const ShPoint3d &extensionPoint);
bool checkPossibleToExtend(ShLine *lineToExtend, ShEntityPartToExtend entityPartToExtend,
Expand All @@ -116,6 +122,12 @@ class ShArcExtensionPointFinder : public ShExtensionPointFinder {
virtual void visit(ShLine *line);
virtual void visit(ShCircle *circle);
virtual void visit(ShArc *arc);
virtual void visit(ShDimLinear *dimLinear);
virtual void visit(ShDimAligned *dimAligned);
virtual void visit(ShDimRadius *dimRadius);
virtual void visit(ShDimDiameter *dimDiameter);
virtual void visit(ShDimArcLength *dimArcLength);
virtual void visit(ShDimAngular *dimAngular);

bool checkPossibleToExtend(ShArc *arcToExtend, ShEntityPartToExtend entityPartToExtend, const ShPoint3d &extensionPoint);
bool checkPossibleToExtend(ShArc *arcToExtend, ShEntityPartToExtend entityPartToExtend,
Expand Down
168 changes: 168 additions & 0 deletions ShCAD/ShCAD/Entity/Private/ShTrimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#include "Entity\Leaf\ShArc.h"
#include "Base\ShMath.h"
#include "ShFootOfPerpendicularVisitor.h"
#include "Entity\Composite\Dim\ShDimLinear.h"
#include "Entity\Composite\Dim\ShDimAligned.h"
#include "Entity\Composite\Dim\ShDimRadius.h"
#include "Entity\Composite\Dim\ShDimDiameter.h"
#include "Entity\Composite\Dim\ShDimArcLength.h"
#include "Entity\Composite\Dim\ShDimAngular.h"

ShTrimer::ShTrimer(const QLinkedList<ShEntity*> &baseEntities, const ShPoint3d &clickPoint, QLinkedList<ShEntity*> &trimedEntities, bool &valid)
:baseEntities(baseEntities), clickPoint(clickPoint), trimedEntities(trimedEntities), valid(valid) {
Expand Down Expand Up @@ -378,6 +384,60 @@ void ShLineTrimPointFinder::visit(ShArc *arc) {
}
}

void ShLineTrimPointFinder::visit(ShDimLinear *dimLinear) {

ShLineTrimPointFinder visitor(this->lineToTrim, this->clickPoint, this->betweenStartAndClickTrimPointList, this->betweenEndAndClickTrimPointList);

auto itr = dimLinear->begin();
for (itr; itr != dimLinear->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineTrimPointFinder::visit(ShDimAligned *dimAligned) {

ShLineTrimPointFinder visitor(this->lineToTrim, this->clickPoint, this->betweenStartAndClickTrimPointList, this->betweenEndAndClickTrimPointList);

auto itr = dimAligned->begin();
for (itr; itr != dimAligned->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineTrimPointFinder::visit(ShDimRadius *dimRadius) {

ShLineTrimPointFinder visitor(this->lineToTrim, this->clickPoint, this->betweenStartAndClickTrimPointList, this->betweenEndAndClickTrimPointList);

auto itr = dimRadius->begin();
for (itr; itr != dimRadius->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineTrimPointFinder::visit(ShDimDiameter *dimDiameter) {

ShLineTrimPointFinder visitor(this->lineToTrim, this->clickPoint, this->betweenStartAndClickTrimPointList, this->betweenEndAndClickTrimPointList);

auto itr = dimDiameter->begin();
for (itr; itr != dimDiameter->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineTrimPointFinder::visit(ShDimArcLength *dimArcLength) {

ShLineTrimPointFinder visitor(this->lineToTrim, this->clickPoint, this->betweenStartAndClickTrimPointList, this->betweenEndAndClickTrimPointList);

auto itr = dimArcLength->begin();
for (itr; itr != dimArcLength->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShLineTrimPointFinder::visit(ShDimAngular *dimAngular) {

ShLineTrimPointFinder visitor(this->lineToTrim, this->clickPoint, this->betweenStartAndClickTrimPointList, this->betweenEndAndClickTrimPointList);

auto itr = dimAngular->begin();
for (itr; itr != dimAngular->end(); ++itr)
(*itr)->accept(&visitor);
}

bool ShLineTrimPointFinder::checkIntersectLiesOnStartEnd(const ShPoint3d &intersect, const ShPoint3d &start, const ShPoint3d &end) {

if (math::compare(start.x, intersect.x) == 0 &&
Expand Down Expand Up @@ -522,6 +582,60 @@ void ShCircleTrimPointFinder::visit(ShArc *arc) {
this->appendTrimPointToList(intersect, intersect2);
}

void ShCircleTrimPointFinder::visit(ShDimLinear *dimLinear) {

ShCircleTrimPointFinder visitor(this->circleToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimLinear->begin();
for (itr; itr != dimLinear->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShCircleTrimPointFinder::visit(ShDimAligned *dimAligned) {

ShCircleTrimPointFinder visitor(this->circleToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimAligned->begin();
for (itr; itr != dimAligned->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShCircleTrimPointFinder::visit(ShDimRadius *dimRadius) {

ShCircleTrimPointFinder visitor(this->circleToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimRadius->begin();
for (itr; itr != dimRadius->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShCircleTrimPointFinder::visit(ShDimDiameter *dimDiameter) {

ShCircleTrimPointFinder visitor(this->circleToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimDiameter->begin();
for (itr; itr != dimDiameter->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShCircleTrimPointFinder::visit(ShDimArcLength *dimArcLength) {

ShCircleTrimPointFinder visitor(this->circleToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimArcLength->begin();
for (itr; itr != dimArcLength->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShCircleTrimPointFinder::visit(ShDimAngular *dimAngular) {

ShCircleTrimPointFinder visitor(this->circleToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimAngular->begin();
for (itr; itr != dimAngular->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShCircleTrimPointFinder::appendTrimPointToList(const ShPoint3d &trimPoint) {

double angleCenterToClick = math::getAbsAngle(this->circleToTrim->getCenter().x, this->circleToTrim->getCenter().y,
Expand Down Expand Up @@ -771,6 +885,60 @@ void ShArcTrimPointFinder::visit(ShArc *arc) {
}
}

void ShArcTrimPointFinder::visit(ShDimLinear *dimLinear) {

ShArcTrimPointFinder visitor(this->arcToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimLinear->begin();
for (itr; itr != dimLinear->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcTrimPointFinder::visit(ShDimAligned *dimAligned) {

ShArcTrimPointFinder visitor(this->arcToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimAligned->begin();
for (itr; itr != dimAligned->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcTrimPointFinder::visit(ShDimRadius *dimRadius) {

ShArcTrimPointFinder visitor(this->arcToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimRadius->begin();
for (itr; itr != dimRadius->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcTrimPointFinder::visit(ShDimDiameter *dimDiameter) {

ShArcTrimPointFinder visitor(this->arcToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimDiameter->begin();
for (itr; itr != dimDiameter->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcTrimPointFinder::visit(ShDimArcLength *dimArcLength) {

ShArcTrimPointFinder visitor(this->arcToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimArcLength->begin();
for (itr; itr != dimArcLength->end(); ++itr)
(*itr)->accept(&visitor);
}

void ShArcTrimPointFinder::visit(ShDimAngular *dimAngular) {

ShArcTrimPointFinder visitor(this->arcToTrim, this->clickPoint, this->clockWiseTrimPointList, this->antiClockWiseTrimPointList);

auto itr = dimAngular->begin();
for (itr; itr != dimAngular->end(); ++itr)
(*itr)->accept(&visitor);
}

bool ShArcTrimPointFinder::checkIntersectLiesOnStartEnd(const ShPoint3d &intersect, const ShPoint3d &start, const ShPoint3d &end) {

if (math::compare(start.x, intersect.x) == 0 &&
Expand Down
18 changes: 18 additions & 0 deletions ShCAD/ShCAD/Entity/Private/ShTrimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class ShLineTrimPointFinder : public ShVisitor {
virtual void visit(ShLine *line);
virtual void visit(ShCircle *circle);
virtual void visit(ShArc *arc);
virtual void visit(ShDimLinear *dimLinear);
virtual void visit(ShDimAligned *dimAligned);
virtual void visit(ShDimRadius *dimRadius);
virtual void visit(ShDimDiameter *dimDiameter);
virtual void visit(ShDimArcLength *dimArcLength);
virtual void visit(ShDimAngular *dimAngular);

private:
bool checkIntersectLiesOnStartEnd(const ShPoint3d &intersect, const ShPoint3d &start, const ShPoint3d &end);
Expand Down Expand Up @@ -82,6 +88,12 @@ class ShCircleTrimPointFinder : public ShVisitor {
virtual void visit(ShLine *line);
virtual void visit(ShCircle *circle);
virtual void visit(ShArc *arc);
virtual void visit(ShDimLinear *dimLinear);
virtual void visit(ShDimAligned *dimAligned);
virtual void visit(ShDimRadius *dimRadius);
virtual void visit(ShDimDiameter *dimDiameter);
virtual void visit(ShDimArcLength *dimArcLength);
virtual void visit(ShDimAngular *dimAngular);

private:
void appendTrimPointToList(const ShPoint3d &trimPoint);
Expand Down Expand Up @@ -109,6 +121,12 @@ class ShArcTrimPointFinder : public ShVisitor {
virtual void visit(ShLine *line);
virtual void visit(ShCircle *circle);
virtual void visit(ShArc *arc);
virtual void visit(ShDimLinear *dimLinear);
virtual void visit(ShDimAligned *dimAligned);
virtual void visit(ShDimRadius *dimRadius);
virtual void visit(ShDimDiameter *dimDiameter);
virtual void visit(ShDimArcLength *dimArcLength);
virtual void visit(ShDimAngular *dimAngular);

private:
bool checkIntersectLiesOnStartEnd(const ShPoint3d &intersect, const ShPoint3d &start, const ShPoint3d &end);
Expand Down

0 comments on commit ec7a0d7

Please sign in to comment.