}
// --- Group 1 ---
+ double centroid[3];
+
wsp->InsertCollectionAfter_();
p[0] = (lstX[0]+lstX[3])/2;
p[1] = (lstY[0]+lstY[3])/2;
wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
p[0] = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4; p[1] = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4; p[2] = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4;
wsp->InsertPoint(p[0] ,p[1], p[2],"");
-
+ std::copy(std::begin(p), std::end(p), std::begin(centroid));
// --- Group 2 ---
wsp->InsertCollectionAfter_();
normalOut[0] = normalOut[0]/norm;
normalOut[1] = normalOut[1]/norm;
normalOut[2] = normalOut[2]/norm;
- bbSetOutputOut(normalOut);
+
+ std::vector<double> outputData;
+ outputData.insert(outputData.end(), ¢roid[0], ¢roid[3]);
+ outputData.insert(outputData.end(), &normalOut[0], &normalOut[3]);
+
+ bbSetOutputOut(outputData);
+ //bbSetOutputOut(normalOut);
// --- Finish ---
wsp->SetOutputBox();
void ShowNPoints_Tools::CreateExpandedSurface()
{
//
- //Set Input to 0 as this function is only used by the popup menu
+ //Set Input to 0 as this function should only be executed manually but still update its children.
bbSetInputType(0);
//
//
wsp->StopTrackPoint();
if((wsp->GetLstModelShowNPointsSize()==1) && (bbGetInputMesh()!=NULL ) && (wsp->GetModelShowNPoints()->GetLstPointsSize()>0))
{
+ //Set Input to 0 as this function should only be executed manually but still update its children.
+ //bbSetInputType(0);
+ //
std::vector<double> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
std::vector<double> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
std::vector<double> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
{
//
//Set Input to 0 as this function is only used by the popup menu
- bbSetInputType(0);
+ //bbSetInputType(0);
//
//
WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
double np[3], dV[3];
int addNormal = 1;
- //Add new groups on both sides from the main group
- for(int group = 0; group < 3; group++){
+ //Add new groups on both sides from the original spline
+ for(int group = 0; group < 2; group++){
for(int i = 0; i < (int) lstX.size(); i++){
dV[0] = lstX[i] - centroid[0];
dV[1] = lstY[i] - centroid[1];
np[2] = lstZ[i] + dV[2]*4 + ((normal[2]*2)*addNormal);
wsp->AddPoint(np[0] ,np[1], np[2],"");
}
- addNormal--;
- if(group < 2)wsp->InsertCollectionAfter_();
+ addNormal = -1;
+ if(group < 1)wsp->InsertCollectionAfter_();
}
std::vector<double> outData = {centroid[0], centroid[1], centroid[2], normal[0], normal[1], normal[2]};
WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
wsp->StopAutoAddPoints();
wsp->StopTrackPoint();
-
- if((wsp->GetLstModelShowNPointsSize()==1 || wsp->GetLstModelShowNPointsSize() == 3)
+
+ if((wsp->GetLstModelShowNPointsSize()==1 || wsp->GetLstModelShowNPointsSize() == 2)
&& (wsp->GetModelShowNPoints()->GetLstPointsSize()>0)
&& (bbGetInputParams().size() == 4))
{
std::vector<double> params = bbGetInputParams();
double direction = params[3];
double centroid[3] = {params[0], params[1], params[2]};
- int numCollection = wsp->GetLstModelShowNPointsSize()==1?0:1;
double dV[3], currPoint[3], mdfdPoint[3];
std::vector<double> modPoint;
int pointsPerSpline = wsp->GetModelShowNPoints()->GetLstPointsSize();
for(int i = 0; i < pointsPerSpline; i++){
- wsp->GetCollectionPoint(numCollection, i, currPoint);
+ wsp->GetCollectionPoint(0, i, currPoint);
dV[0] = currPoint[0] - centroid[0];
dV[1] = currPoint[1] - centroid[1];
dV[2] = currPoint[2] - centroid[2];
vtkMath::MultiplyScalar(dV, direction);
vtkMath::Add(currPoint, dV, mdfdPoint);
modPoint.insert(modPoint.begin(), std::begin(mdfdPoint), std::end(mdfdPoint));
- wsp->SetCollectionPoint(numCollection, i, modPoint);
+ wsp->SetCollectionPoint(0, i, modPoint);
- if(wsp->GetLstModelShowNPointsSize() == 3){
- wsp->GetCollectionPoint(0, i, currPoint);
- vtkMath::Add(currPoint, dV, mdfdPoint);
- modPoint.insert(modPoint.begin(), std::begin(mdfdPoint), std::end(mdfdPoint));
- wsp->SetCollectionPoint(0, i, modPoint);
-
- wsp->GetCollectionPoint(2, i, currPoint);
+ if(wsp->GetLstModelShowNPointsSize() == 2){
+ wsp->GetCollectionPoint(1, i, currPoint);
vtkMath::Add(currPoint, dV, mdfdPoint);
modPoint.insert(modPoint.begin(), std::begin(mdfdPoint), std::end(mdfdPoint));
- wsp->SetCollectionPoint(2, i, modPoint);
+ wsp->SetCollectionPoint(1, i, modPoint);
}
}
}
wsp->SetOutputBox();
wsp->UndoRedo_SaveCollection();
}
+
+void ShowNPoints_Tools::ExpandPatch()
+{
+ WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+ wsp->StopAutoAddPoints();
+ wsp->StopTrackPoint();
+ if((wsp->GetLstModelShowNPointsSize() == 3)
+ && (wsp->GetLstPointsX().size() == 13)
+ && (bbGetInputParams().size() == 4))
+ {
+ std::vector<double> params = bbGetInputParams();
+ double direction = params[3];
+ double centroid[3] = {params[0], params[1], params[2]};
+
+ std::vector<double> modPoint(3);
+ double currentPoint[3], dV[3], mdfdPoint[3];
+ for(int group = 0; group < 3; group++){
+ if(group == 1){
+ cout << "collection: " << group << " i: " << "0" << endl;
+ wsp->GetCollectionPoint(group, 0, currentPoint);
+ dV[0] = currentPoint[0] - centroid[0];
+ dV[1] = currentPoint[1] - centroid[1];
+ dV[2] = currentPoint[2] - centroid[2];
+ vtkMath::Normalize(dV);
+ vtkMath::MultiplyScalar(dV, direction);
+ vtkMath::Add(currentPoint, dV, mdfdPoint);
+ modPoint.insert(modPoint.begin(), std::begin(mdfdPoint), std::end(mdfdPoint));
+ wsp->SetCollectionPoint(group, 0, modPoint);
+ cout << "collection: " << group << " i: " << "2" << endl;
+ wsp->GetCollectionPoint(group, 2, currentPoint);
+ dV[0] = currentPoint[0] - centroid[0];
+ dV[1] = currentPoint[1] - centroid[1];
+ dV[2] = currentPoint[2] - centroid[2];
+ vtkMath::Normalize(dV);
+ vtkMath::MultiplyScalar(dV, direction);
+ vtkMath::Add(currentPoint, dV, mdfdPoint);
+ modPoint.insert(modPoint.begin(), std::begin(mdfdPoint), std::end(mdfdPoint));
+ wsp->SetCollectionPoint(group, 2, modPoint);
+ }else{
+ for(int i = 0; i < 5; i++){
+ wsp->GetCollectionPoint(group,i, currentPoint);
+ dV[0] = currentPoint[0] - centroid[0];
+ dV[1] = currentPoint[1] - centroid[1];
+ dV[2] = currentPoint[2] - centroid[2];
+ vtkMath::Normalize(dV);
+ vtkMath::MultiplyScalar(dV, direction);
+ vtkMath::Add(currentPoint, dV, mdfdPoint);
+ modPoint.insert(modPoint.begin(), std::begin(mdfdPoint), std::end(mdfdPoint));
+ cout << "collection: " << group << " i: " << i << endl;
+ wsp->SetCollectionPoint(group, i, modPoint);
+ }
+ }
+ }
+ }else{
+ printf("PG ShowNPoints_Tools::ExpandPatch Warning groups, points or params invalid. need 3 groups of points, need 4 params(centroid, and direction 1 or -1)\n");
+ }
+ // --- Finish ---
+ wsp->SetOutputBox();
+ wsp->UndoRedo_SaveCollection();
+}
+
/**
-* Given a cutting surface, expand the distance between the edge splines and the middle spline. making it "wider".
+* Given a cutting surface, expand the distance between the edge splines and the middle spline. making it "wider" or "thicker".
*/
void ShowNPoints_Tools::WidenSurface()
{
wsp->StopAutoAddPoints();
wsp->StopTrackPoint();
- if((wsp->GetLstModelShowNPointsSize()==3)
+ if((wsp->GetLstModelShowNPointsSize()==2)
&& (wsp->GetModelShowNPoints()->GetLstPointsSize()>0)
&& (bbGetInputParams().size() == 4))
{
std::vector<double> modifiedPoint;
for(int i = 0; i < pointsPerSpline; i++){
wsp->GetCollectionPoint(0, i, pointSp1);
- wsp->GetCollectionPoint(2, i, pointSp2);
+ wsp->GetCollectionPoint(1, i, pointSp2);
vtkMath::Add(pointSp1, normal, pointSp1);
vtkMath::Subtract(pointSp2, normal, pointSp2);
modifiedPoint.insert(modifiedPoint.begin(), std::begin(pointSp1), std::end(pointSp1));
wsp->SetCollectionPoint(0, i, modifiedPoint);
modifiedPoint.insert(modifiedPoint.begin(), std::begin(pointSp2), std::end(pointSp2));
- wsp->SetCollectionPoint(2, i, modifiedPoint);
+ wsp->SetCollectionPoint(1, i, modifiedPoint);
}
}else{
{
WidenSurface();
} // if Type
+ if(bbGetInputType()==340)
+ {
+ ExpandPatch();
+ } // if Type
} // if bbGetInputWidgetShowNPoints
}
//=====