//=====
#include "bbcreaMaracasVisuShowNPoints_Tools.h"
#include "bbcreaMaracasVisuPackage.h"
+
+
namespace bbcreaMaracasVisu
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints_Tools)
BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints_Tools,bbtk::AtomicBlackBox);
+
+
+void ShowNPoints_Tools::NearestPointToMesh( vtkPoints *points,vtkStaticPointLocator *pointLocator,double *spc,double *p,double *pM)
+{
+
+ p[0] = p[0] * spc[0];
+ p[1] = p[1] * spc[1];
+ p[2] = p[2] * spc[2];
+ points->GetPoint( pointLocator->FindClosestPoint(p) , pM );
+ pM[0] = pM[0] / spc[0];
+ pM[1] = pM[1] / spc[1];
+ pM[2] = pM[2] / spc[2];
+}
+
void ShowNPoints_Tools::CreatePatch01()
{
- bbGetInputWidgetShowNPoints()->CreatePatch01( );
+ WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+ if ( (wsp->GetLstModelShowNPointsSize()==1) &&
+ (wsp->GetModelShowNPoints()->GetLstPointsSize()==4) &&
+ (bbGetInputMesh()!=NULL ) )
+ {
+ double spc[3];
+ spc[0] = bbGetInputSpacing()[0];
+ spc[1] = bbGetInputSpacing()[1];
+ spc[2] = bbGetInputSpacing()[2];
+ vtkPoints *points = bbGetInputMesh()->GetPoints();
+ vtkStaticPointLocator *pointLocator = vtkStaticPointLocator::New();
+ pointLocator->SetDataSet( bbGetInputMesh() );
+ pointLocator->BuildLocator();
+
+ wsp->StopTrackPoint();
+ double p[3],pM[3];
+ double dx,dy,dz,s;
+ std::vector<int> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
+ std::vector<int> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
+ std::vector<int> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
+
+ // --- Group 0 ---
+ wsp->ErasePoint( 2 );
+ wsp->ErasePoint( 2 );
+ dx = lstX[1]-lstX[0];
+ dy = lstY[1]-lstY[0];
+ dz = lstZ[1]-lstZ[0];
+ s=0.33333;
+ p[0] = lstX[0] + dx*s;
+ p[1] = lstY[0] + dy*s;
+ p[2] = lstZ[0] + dz*s;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+ s=s*2;
+ p[0] = lstX[0] + dx*s;
+ p[1] = lstY[0] + dy*s;
+ p[2] = lstZ[0] + dz*s;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0],pM[1], pM[2],"");
+
+ // --- Group 1 ---
+ wsp->OnInsertCollectionAfter_();
+ p[0] = (lstX[0]+lstX[3])/2;
+ p[1] = (lstY[0]+lstY[3])/2;
+ p[2] = (lstZ[0]+lstZ[3])/2;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+ p[0] = (lstX[1]+lstX[2])/2;
+ p[1] = (lstY[1]+lstY[2])/2;
+ p[2] = (lstZ[1]+lstZ[2])/2;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ 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],"");
+
+ // --- Group 2 ---
+ wsp->OnInsertCollectionAfter_();
+ p[0] = lstX[3];
+ p[1] = lstY[3];
+ p[2] = lstZ[3];
+ wsp->InsertPoint(p[0] ,p[1], p[2],"");
+ p[0] = lstX[2];
+ p[1] = lstY[2];
+ p[2] = lstZ[2];
+ wsp->InsertPoint(p[0] ,p[1], p[2],"");
+ dx = lstX[2]-lstX[3];
+ dy = lstY[2]-lstY[3];
+ dz = lstZ[2]-lstZ[3];
+ s=0.33333;
+ p[0] = lstX[3] + dx*s;
+ p[1] = lstY[3] + dy*s;
+ p[2] = lstZ[3] + dz*s;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+ s=s*2;
+ p[0] = lstX[3] + dx*s;
+ p[1] = lstY[3] + dy*s;
+ p[2] = lstZ[3] + dz*s;
+ NearestPointToMesh(points, pointLocator, spc, p,pM);
+ wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+
+ wsp->SetOutputBox();
+ pointLocator->Delete();
+ } else {
+ printf("EED ShowNPoints_Tools::CreatePatch01 Warning patch not apply. Need juste one group with four points\n");
+ } // if
}
+
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
bbSetInputType(0);
bbSetInputMesh(NULL);
bbSetInputWidgetShowNPoints(NULL);
+
+ std::vector<double> spc;
+ spc.push_back(1);
+ spc.push_back(1);
+ spc.push_back(1);
+ bbSetInputSpacing(spc);
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
#include "iostream"
#include "WidgetShowNPoints.h"
+
+
#include "vtkPolyData.h"
+#include <vtkStaticPointLocator.h>
namespace bbcreaMaracasVisu
{
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
BBTK_DECLARE_INPUT(WidgetShowNPoints,WidgetShowNPoints*);
+ BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
BBTK_DECLARE_INPUT(Mesh,vtkPolyData*);
BBTK_DECLARE_INPUT(Type,int);
// BBTK_DECLARE_OUTPUT(Out,double);
void Process();
void CreatePatch01();
+ void NearestPointToMesh( vtkPoints *points, vtkStaticPointLocator *pointLocator, double *spc , double *p , double *pM );
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
BBTK_DESCRIPTION("No Description.");
BBTK_CATEGORY("empty");
BBTK_INPUT(ShowNPoints_Tools,WidgetShowNPoints,"WidgetShowNPoints",WidgetShowNPoints*,"");
+ BBTK_INPUT(ShowNPoints_Tools,Spacing,"(default [1,1,1] )Spacing",std::vector<double>,"");
BBTK_INPUT(ShowNPoints_Tools,Mesh,"Mesh en format vtkPolyData ",vtkPolyData*,"");
BBTK_INPUT(ShowNPoints_Tools,Type,"(default 0) 0:Nothing 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 200:Tool_1 - Create Mesh (based with one group and 4 points)",int,"");
// BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,"");
return lstIndexs;
}
-
-void WidgetShowNPoints::CreatePatch01()
+//------------------------------------------------------------------------
+int WidgetShowNPoints::GetLstModelShowNPointsSize()
{
- if ( (lstModelShowNPoints.size()==1) && (GetModelShowNPoints()->GetLstPointsSize()==4) )
- {
- StopTrackPoint();
- double px,py,pz;
- double dx,dy,dz,s;
- std::vector<int> lstX = GetModelShowNPoints()->GetLstPointsX();
- std::vector<int> lstY = GetModelShowNPoints()->GetLstPointsY();
- std::vector<int> lstZ = GetModelShowNPoints()->GetLstPointsZ();
-
- // --- Group 0 ---
- ErasePoint( 2 );
- ErasePoint( 2 );
- dx=lstX[1]-lstX[0];
- dy=lstY[1]-lstY[0];
- dz=lstZ[1]-lstZ[0];
- s=0.33333;
- px = lstX[0] + dx*s;
- py = lstY[0] + dy*s;
- pz = lstZ[0] + dz*s;
- InsertPoint(px ,py, pz,"");
- s=s*2;
- px = lstX[0] + dx*s;
- py = lstY[0] + dy*s;
- pz = lstZ[0] + dz*s;
- InsertPoint(px ,py, pz,"");
-
- // --- Group 1 ---
- OnInsertCollectionAfter_();
- px = (lstX[0]+lstX[3])/2;
- py = (lstY[0]+lstY[3])/2;
- pz = (lstZ[0]+lstZ[3])/2;
- InsertPoint(px ,py, pz,"");
- px = (lstX[1]+lstX[2])/2;
- py = (lstY[1]+lstY[2])/2;
- pz = (lstZ[1]+lstZ[2])/2;
- InsertPoint(px ,py, pz,"");
- px = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4;
- py = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4;
- pz = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4;
- InsertPoint(px ,py, pz,"");
-
-
- // --- Group 2 ---
- OnInsertCollectionAfter_();
- px = lstX[3];
- py = lstY[3];
- pz = lstZ[3];
- InsertPoint(px ,py, pz,"");
- px = lstX[2];
- py = lstY[2];
- pz = lstZ[2];
- InsertPoint(px ,py, pz,"");
- dx=lstX[2]-lstX[3];
- dy=lstY[2]-lstY[3];
- dz=lstZ[2]-lstZ[3];
- s=0.33333;
- px = lstX[3] + dx*s;
- py = lstY[3] + dy*s;
- pz = lstZ[3] + dz*s;
- InsertPoint(px ,py, pz,"");
- s=s*2;
- px = lstX[3] + dx*s;
- py = lstY[3] + dy*s;
- pz = lstZ[3] + dz*s;
- InsertPoint(px ,py, pz,"");
-
-
- SetOutputBox();
- } else {
- printf("EED WidgetShowNPoints::CreatePatch01 Warning patch not apply. Need juste one group with four points\n");
- } // if
+ return lstModelShowNPoints.size();
}