# ----------------------------------
# - BBTKGEditor v 1.5 BBG BlackBox Diagram file
-# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg
+# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg
# ----------------------------------
APP_START
PORT
In8:"- Delete group"
PORT
-In9:"Tool - 3 points to surface"
+In9:"Tool - 3 or 4 points to surface"
FIN_BOX
BOX
creaMaracasVisu:ShowNPoints_Tools:Box60
-301.046687:92.535608:-900.000000
-276.526687:90.035608:-900.000000
PORT
-In0:"Tool - 4 points to surface"
-PORT
-In1:"Tool - Inverse Normals"
+In0:"Tool - Inverse Normals"
FIN_BOX
BOX
std:VectorFilterString:Box112
-276.139970:71.814693:-900.000000
-248.099970:69.314693:-900.000000
PORT
-In0:"0 1 2 3 4 5 6 7 8 9 10 11 12"
+In0:"0 1 2 3 4 5 6 7 8 9 10 11"
PORT
-In1:"1 5 10 20 30 40 50 0 100 110 190 200 210"
+In1:"1 5 10 20 30 40 50 0 100 110 200 210"
PORT
Type:"2"
FIN_BOX
Box100:Out:Box95:Param
NumberOfControlPoints:0
CONNECTION
-Box99:Widget:Box101:Widget4
-NumberOfControlPoints:0
-CONNECTION
Box99:BoxChange:Box103:In4
NumberOfControlPoints:0
CONNECTION
Box117:Widget:Box44:Widget3
NumberOfControlPoints:0
CONNECTION
-Box118:Widget:Box101:Widget1
-NumberOfControlPoints:0
-CONNECTION
Box118:Out:Box96:ScalarFactor
NumberOfControlPoints:0
CONNECTION
Box127:Widget:Box129:Widget4
NumberOfControlPoints:0
CONNECTION
-Box129:Widget:Box101:Widget7
+Box121:Widget:Box129:Widget6
NumberOfControlPoints:0
CONNECTION
-Box121:Widget:Box129:Widget6
+Box99:Widget:Box101:Widget7
+NumberOfControlPoints:0
+CONNECTION
+Box118:Widget:Box101:Widget4
+NumberOfControlPoints:0
+CONNECTION
+Box129:Widget:Box101:Widget1
NumberOfControlPoints:0
APP_END
# ----------------------------------
# - BBTKGEditor v 1.5 BBS BlackBox Script (Complex Box)
-# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs
+# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs
# ----------------------------------
include std
set Box58.In6 "----------------------"
set Box58.In7 "+> Insert group after"
set Box58.In8 "- Delete group"
- set Box58.In9 "Tool - 3 points to surface"
+ set Box58.In9 "Tool - 3 or 4 points to surface"
new creaMaracasVisu:ShowNPoints_Tools Box60
set Box110.TargetReduction "0.5"
new std:AddStringToVector Box111
- set Box111.In0 "Tool - 4 points to surface"
- set Box111.In1 "Tool - Inverse Normals"
+ set Box111.In0 "Tool - Inverse Normals"
new std:VectorFilterString Box112
- set Box112.In0 "0 1 2 3 4 5 6 7 8 9 10 11 12"
- set Box112.In1 "1 5 10 20 30 40 50 0 100 110 190 200 210"
+ set Box112.In0 "0 1 2 3 4 5 6 7 8 9 10 11"
+ set Box112.In1 "1 5 10 20 30 40 50 0 100 110 200 210"
set Box112.Type "2"
new std:ConcatStrings Box114
connect Box95.Out Box96.In
connect Box99.Out Box100.In1
connect Box100.Out Box95.Param
-connect Box99.Widget Box101.Widget4
connect Box99.BoxChange Box103.In4
connect Box103.BoxChange Box98.boxexecute
connect Box71.Out Box105.wxVtkBaseView
connect Box78.Widget Box117.Widget2
connect Box80.Widget Box117.Widget4
connect Box117.Widget Box44.Widget3
-connect Box118.Widget Box101.Widget1
connect Box118.Out Box96.ScalarFactor
connect Box118.BoxChange Box103.In3
connect Box119.Out Box58.StringVector
connect Box120.BoxChange Box126.In1
connect Box126.BoxChange Box31.BoxExecute
connect Box127.Widget Box129.Widget4
-connect Box129.Widget Box101.Widget7
connect Box121.Widget Box129.Widget6
+connect Box99.Widget Box101.Widget7
+connect Box118.Widget Box101.Widget4
+connect Box129.Widget Box101.Widget1
# Complex input ports
input point showNpoints.In " "
{
//printf("PG ShowNPoints_Tools::CreatePatch_3points Entered patch 3 points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
- wsp->StopAutoAddPoints();
- wsp->StopTrackPoint();
- if ( (wsp->GetLstModelShowNPointsSize()==1) &&
- (wsp->GetModelShowNPoints()->GetLstPointsSize()==3) &&
- (bbGetInputMesh()!=NULL ) )
- {
- std::vector<int> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
- std::vector<int> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
- std::vector<int> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
-
- double pA[3];
- pA[0] = lstX[0];
- pA[1] = lstY[0];
- pA[2] = lstZ[0];
- double pB[3];
- pB[0] = lstX[1];
- pB[1] = lstY[1];
- pB[2] = lstZ[1];
- double pC[3];
- pC[0] = lstX[2];
- pC[1] = lstY[2];
- pC[2] = lstZ[2];
+
+ std::vector<double> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
+ std::vector<double> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
+ std::vector<double> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
+
+ double pA[3];
+ pA[0] = lstX[0];
+ pA[1] = lstY[0];
+ pA[2] = lstZ[0];
+ double pB[3];
+ pB[0] = lstX[1];
+ pB[1] = lstY[1];
+ pB[2] = lstZ[1];
+ double pC[3];
+ pC[0] = lstX[2];
+ pC[1] = lstY[2];
+ pC[2] = lstZ[2];
- double v[3];
- double u[3];
- vtkMath::Subtract(pC,pA,v);
- vtkMath::Subtract(pB,pA,u);
-
- /**point in AC closest to B.
- *formula t=(V)dot(U)/(V)dot(V)
- */
- double t = vtkMath::Dot(v,u)/vtkMath::Dot(v,v);
- /**nP found point
- *formula A+t(C-A) -> A+tV
- */
- vtkMath::MultiplyScalar(v, t);
- double nP[3];
- vtkMath::Add(pA, v, nP);
-
- //calculate direction vector from found point to B
- double dirVector[3];
- vtkMath::Subtract(pB, nP, dirVector);
-
- double pointAdd[3];
- double pointSub[3];
-
- //Add and subtract direction vector to A and C to find the 4 points to create the patch,
-
- std::vector<int> resListX;
- std::vector<int> resListY;
- std::vector<int> resListZ;
-
- vtkMath::Add(pA, dirVector, pointAdd);
- vtkMath::Subtract(pA, dirVector, pointSub);
-
- resListX.push_back(pointSub[0]);
- resListY.push_back(pointSub[1]);
- resListZ.push_back(pointSub[2]);
+ double v[3];
+ double u[3];
+ vtkMath::Subtract(pC,pA,v);
+ vtkMath::Subtract(pB,pA,u);
+
+ /**point in AC closest to B.
+ *formula t=(V)dot(U)/(V)dot(V)
+ */
+ double t = vtkMath::Dot(v,u)/vtkMath::Dot(v,v);
+ /**nP found point
+ *formula A+t(C-A) -> A+tV
+ */
+ vtkMath::MultiplyScalar(v, t);
+ double nP[3];
+ vtkMath::Add(pA, v, nP);
+
+ //calculate direction vector from found point to B
+ double dirVector[3];
+ vtkMath::Subtract(pB, nP, dirVector);
+
+ double pointAdd[3];
+ double pointSub[3];
+
+ //Add and subtract direction vector to A and C to find the 4 points to create the patch,
+
+ std::vector<double> resListX;
+ std::vector<double> resListY;
+ std::vector<double> resListZ;
+
+ vtkMath::Add(pA, dirVector, pointAdd);
+ vtkMath::Subtract(pA, dirVector, pointSub);
+
+ resListX.push_back(pointSub[0]);
+ resListY.push_back(pointSub[1]);
+ resListZ.push_back(pointSub[2]);
- resListX.push_back(pointAdd[0]);
- resListY.push_back(pointAdd[1]);
- resListZ.push_back(pointAdd[2]);
-
-
- vtkMath::Add(pC, dirVector, pointAdd);
- vtkMath::Subtract(pC, dirVector, pointSub);
-
- resListX.push_back(pointAdd[0]);
- resListY.push_back(pointAdd[1]);
- resListZ.push_back(pointAdd[2]);
-
- resListX.push_back(pointSub[0]);
- resListY.push_back(pointSub[1]);
- resListZ.push_back(pointSub[2]);
- //printf("PG ShowNPoints_Tools::CreatePatch_3points Calls CreatePatch_Points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
- //Create patch given the previously calculated points (4 points)
- CreatePatch_Points(resListX, resListY, resListZ);
- }else{
- //printf("PG ShowNPoints_Tools::CreatePatch_3points Warning patch not apply. Need only one group of 3 points\n");
- }
+ resListX.push_back(pointAdd[0]);
+ resListY.push_back(pointAdd[1]);
+ resListZ.push_back(pointAdd[2]);
+
+
+ vtkMath::Add(pC, dirVector, pointAdd);
+ vtkMath::Subtract(pC, dirVector, pointSub);
+
+ resListX.push_back(pointAdd[0]);
+ resListY.push_back(pointAdd[1]);
+ resListZ.push_back(pointAdd[2]);
+
+ resListX.push_back(pointSub[0]);
+ resListY.push_back(pointSub[1]);
+ resListZ.push_back(pointSub[2]);
+
+ //Create patch given the previously calculated points (4 points)
+ CreatePatch_Points(resListX, resListY, resListZ);
}
void ShowNPoints_Tools::CreatePatch_4points()
+{
+ WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+
+ std::vector<double> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
+ std::vector<double> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
+ std::vector<double> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
+ CreatePatch_Points(lstX, lstY, lstZ);
+}
+
+void ShowNPoints_Tools::InitCreatePatch_Points()
{
WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
wsp->StopAutoAddPoints();
wsp->StopTrackPoint();
- if ( (wsp->GetLstModelShowNPointsSize()==1) &&
- (wsp->GetModelShowNPoints()->GetLstPointsSize()==4) &&
- (bbGetInputMesh()!=NULL ) )
- {
- std::vector<int> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
- std::vector<int> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
- std::vector<int> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
- CreatePatch_Points(lstX, lstY, lstZ);
- }else{
- printf("PG ShowNPoints_Tools::CreatePatch_4points Warning patch not apply. Need only one group of 4 points\n");
+ if((wsp->GetLstModelShowNPointsSize()==1) && (bbGetInputMesh()!=NULL )){
+ if(wsp->GetModelShowNPoints()->GetLstPointsSize()==4){
+ CreatePatch_4points();
+ }
+ else if(wsp->GetModelShowNPoints()->GetLstPointsSize()==3){
+ CreatePatch_3points();
+ }
+ else{
+ printf("PG ShowNPoints_Tools::CreatePatch_Npoints Warning patch not apply. Number of points is invalid. Group should have 3 or 4 points\n");
+ }
+ }
+ else{
+ printf("PG ShowNPoints_Tools::CreatePatch_Npoints Warning patch not apply. groups or mesh invalid. Need 1 group of 3 or 4 points, and a mesh\n");
}
}
-void ShowNPoints_Tools::CreatePatch_Points(std::vector<int> lstX, std::vector<int> lstY, std::vector<int> lstZ)
+void ShowNPoints_Tools::CreatePatch_Points(std::vector<double> lstX, std::vector<double> lstY, std::vector<double> lstZ)
{
WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
std::vector<long int> lstIdNormalSurface;
modPoint.push_back(centerPoint[2] + direction * normal[2]);
wsp->SetCollectionPoint(1, 1, modPoint);
- wsp->GetViewShowNPoints()->RefreshPoints();
// --- Finish ---
wsp->SetOutputBox();
{
bbGetInputWidgetShowNPoints()->OnResetCollections_();
} // if Type
- if (bbGetInputType()==190)
- {
- CreatePatch_3points();
- } // if Type
if (bbGetInputType()==200)
{
- CreatePatch_4points();
+ InitCreatePatch_Points();
} // if Type
if (bbGetInputType()==210)
{
void CreatePatch_3points();
void CreatePatch_4points();
- void CreatePatch_Points(std::vector<int> lstX, std::vector<int> lstY, std::vector<int> lstZ);
+ void InitCreatePatch_Points();
+ void CreatePatch_Points(std::vector<double> lstX, std::vector<double> lstY, std::vector<double> lstZ);
void NearestPointToMesh( vtkPoints *points, vtkStaticPointLocator *pointLocator, double *spc , double *p , double *pM );
void MovePatchCenter();
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 1:Auto add poits 5:Add Point 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 120:Reset colletion 190:Tool 3 points to surface - Create Mesh (based with one group and 3 points) 200:Tool 4 points to surface - Create Mesh (based with one group and 4 points) 210: Invert points 220: Move patch center",int,"");
- BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required for 200: Normal and direction", std::vector<double>,"");
+ BBTK_INPUT(ShowNPoints_Tools,Type,"(default 0) 0:Nothing 1:Auto add poits 5:Add Point 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 120:Reset colletion 200:Tool 3 or 4 points to surface - Create Mesh (based on one group and 3 or 4 points) 210: Invert points 220: Move patch center",int,"");
+ BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required 200: Normal and direction", std::vector<double>,"");
BBTK_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector<double>, "");
// BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,"");
public bbtk::WxBlackBox
{
BBTK_BLACK_BOX_INTERFACE(ShowNPoints,bbtk::WxBlackBox);
- BBTK_DECLARE_INPUT(In, std::vector<int> );
+ BBTK_DECLARE_INPUT(In, std::vector<double> );
BBTK_DECLARE_INPUT(Renderer, vtkRenderer* );
BBTK_DECLARE_INPUT(Image, vtkImageData* );
BBTK_DECLARE_INPUT(Colour, std::vector<double> );
BBTK_DECLARE_INPUT(Opacity, double );
BBTK_DECLARE_INPUT(Radio, double );
- BBTK_DECLARE_INPUT(InitLstPointsX , std::vector<int> );
- BBTK_DECLARE_INPUT(InitLstPointsY , std::vector<int> );
- BBTK_DECLARE_INPUT(InitLstPointsZ , std::vector<int> );
+ BBTK_DECLARE_INPUT(InitLstPointsX , std::vector<double> );
+ BBTK_DECLARE_INPUT(InitLstPointsY , std::vector<double> );
+ BBTK_DECLARE_INPUT(InitLstPointsZ , std::vector<double> );
BBTK_DECLARE_INPUT(InitLstLabels , std::vector<std::string> );
BBTK_DECLARE_INPUT(InitLstIndexs , std::vector<int> );
BBTK_DECLARE_INPUT(Type, int );
- BBTK_DECLARE_OUTPUT( lstPointsX , std::vector<int> );
- BBTK_DECLARE_OUTPUT( lstPointsY , std::vector<int> );
- BBTK_DECLARE_OUTPUT( lstPointsZ , std::vector<int> );
+ BBTK_DECLARE_OUTPUT( lstPointsX , std::vector<double> );
+ BBTK_DECLARE_OUTPUT( lstPointsY , std::vector<double> );
+ BBTK_DECLARE_OUTPUT( lstPointsZ , std::vector<double> );
BBTK_DECLARE_OUTPUT( lstLabels , std::vector<std::string> );
BBTK_DECLARE_OUTPUT( WidgetShowNPoints, WidgetShowNPoints*);
BBTK_DECLARE_OUTPUT( lstIndexs , std::vector<int> );
BBTK_DESCRIPTION("widget that shows N moints in 3D (vtkActors)");
BBTK_CATEGORY("widgetVtk");
- BBTK_INPUT(ShowNPoints,In,"One Point",std::vector<int>,"");
+ BBTK_INPUT(ShowNPoints,In,"One Point",std::vector<double>,"");
BBTK_INPUT(ShowNPoints,Renderer,"Renderer",vtkRenderer*,"");
BBTK_INPUT(ShowNPoints,Image,"vktkImageData",vtkImageData*,"");
BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector<double>,"colour");
BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor 0..1 (default 1)",double,"");
BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres 1..50 (default 10)",double,"");
- BBTK_INPUT(ShowNPoints,InitLstPointsX,"Initial lst of points X",std::vector<int>,"");
- BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector<int>,"");
- BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector<int>,"");
+ BBTK_INPUT(ShowNPoints,InitLstPointsX,"Initial lst of points X",std::vector<double>,"");
+ BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector<double>,"");
+ BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector<double>,"");
BBTK_INPUT(ShowNPoints,InitLstLabels,"Initial lst of labels",std::vector<std::string>,"");
BBTK_INPUT(ShowNPoints,InitLstIndexs,"Initial lst of indexs sizes",std::vector<int>,"");
BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point, 2:Add/DeleteAll points, 3:As 0 with out save/load option, 4 Multiple NPoints",int,"");
- BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector<int> ,"");
- BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<int> ,"");
- BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<int> ,"");
+ BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector<double> ,"");
+ BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<double> ,"");
+ BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<double> ,"");
BBTK_OUTPUT(ShowNPoints , lstLabels , " list of labels ", std::vector<std::string> ,"");
BBTK_OUTPUT(ShowNPoints , lstIndexs , " list of index sizes ", std::vector<int> ,"");
BBTK_OUTPUT(ShowNPoints , WidgetShowNPoints , " WidgetShowNPoints ", WidgetShowNPoints* ,"");
}
//------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsX()
+std::vector<double> ModelShowNPoints::GetLstPointsX()
{
return lstPointsX;
}
//------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsY()
+std::vector<double> ModelShowNPoints::GetLstPointsY()
{
return lstPointsY;
}
//------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsZ()
+std::vector<double> ModelShowNPoints::GetLstPointsZ()
{
return lstPointsZ;
}
}
//------------------------------------------------------------------------
-void ModelShowNPoints::SetReferencePoint(std::vector<int> ppoint)
+void ModelShowNPoints::SetReferencePoint(std::vector<double> ppoint)
{
mReferencePoint = ppoint;
}
//------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetReferencePoint()
+std::vector<double> ModelShowNPoints::GetReferencePoint()
{
return mReferencePoint;
}
}
//------------------------------------------------------------------------
-void ModelShowNPoints::GetIdPoint(int id, int *x, int *y, int *z)
+void ModelShowNPoints::GetIdPoint(int id, double *x, double *y, double *z)
{
*x = lstPointsX[id];
*y = lstPointsY[id];
}
//------------------------------------------------------------------------
-void ModelShowNPoints::AddPoint(int x, int y, int z, std::string label)
+void ModelShowNPoints::AddPoint(double x, double y, double z, std::string label)
{
lstPointsX.push_back( x );
lstPointsY.push_back( y );
}
//------------------------------------------------------------------------
-int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
+int ModelShowNPoints::InsertPoint(double x, double y, double z, std::string label)
{
if(lstPointsX.size()>1)
{
- std::vector<int> dTotal;
+ std::vector<double> dTotal;
int pos = 1;
double a,b,c,res;
int i,j;
dTotal.push_back (res);
}
//Gets the smallest distance
- int smallTMP = dTotal[0];
+ double smallTMP = dTotal[0];
for (j = 0; j < (int) dTotal.size(); j++)
{
if(dTotal[j]<smallTMP)
// *************** Open contour case End *******************
- std::vector<int>::iterator it;
+ std::vector<double>::iterator it;
//Insert the point in the list of points
it = lstPointsX.begin();
lstPointsX.insert( it+pos, x );
int i , size = (int) (lstPointsX.size());
fprintf(ff,"NumberOfPoints %d \n",size);
fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
- int x, y, z;
+ double x, y, z;
double value;
for (i=0; i<size; i++)
{
x = lstPointsX[i];
y = lstPointsY[i];
z = lstPointsZ[i];
- value = mimage->GetScalarComponentAsDouble(x,y,z,0);
+ value = mimage->GetScalarComponentAsDouble(std::round(x),std::round(y),std::round(z),0);
if (lstLabels[i]!="")
{
tmpLabel=lstLabels[i];
} else{
tmpLabel="<_VOID_>";
}
- fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value , tmpLabel.c_str());
+ fprintf(ff,"%f\t%f\t%f\t%f\t%s\n", x , y , z , value , tmpLabel.c_str());
} // for
}
fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
float value;
- int x,y,z;
+ double x,y,z;
for (i=0; i<size; i++)
{
- fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
+ fscanf(ff,"%lf%lf%lf%f%s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
+ cout << x << " " << y << " " << z << " " << value << endl;
AddPoint(x,y,z, chartmp );
}
return size;
public:
ModelShowNPoints();
~ModelShowNPoints();
- std::vector<int> GetLstPointsX();
- std::vector<int> GetLstPointsY();
- std::vector<int> GetLstPointsZ();
- void GetIdPoint(int id, int *x, int *y, int *z);
- std::string GetIdLabel(int id);
- std::vector<std::string> GetLstLabels();
- void AddPoint(int x, int y, int z, std::string label);
- double DistanceSQ(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1);
- int InsertPoint(int x, int y, int z, std::string label);
- void SavePoints(std::string filename);
- void SavePoints_(FILE* ff);
+ std::vector<double> GetLstPointsX();
+ std::vector<double> GetLstPointsY();
+ std::vector<double> GetLstPointsZ();
+ void GetIdPoint(int id, double *x, double *y, double *z);
+ std::string GetIdLabel(int id);
+ std::vector<std::string> GetLstLabels();
+ void AddPoint(double x, double y, double z, std::string label);
+ double DistanceSQ(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1);
+ int InsertPoint(double x, double y, double z, std::string label);
+ void SavePoints(std::string filename);
+ void SavePoints_(FILE* ff);
- int ReadPoints(std::string filename);
- int ReadPoints_(FILE* ff);
- int GetNearestPoint();
+ int ReadPoints(std::string filename);
+ int ReadPoints_(FILE* ff);
+ int GetNearestPoint();
- int GetLstPointsSize();
- void SetPointId_mReferencePoint(int id);
- int IdInsidePoint();
+ int GetLstPointsSize();
+ void SetPointId_mReferencePoint(int id);
+ int IdInsidePoint();
- void SetPointById(int id, std::vector<double> point);
+ void SetPointById(int id, std::vector<double> point);
- void SetReferencePoint(std::vector<int> ppoint);
- std::vector<int> GetReferencePoint();
- void SetImage(vtkImageData *image);
- std::string CleanSpaces(std::string ss);
- vtkImageData* GetImage();
- void SetRadio(double radio);
- double GetRadio();
- int RenamePoint(std::string label);
- void ErasePoint(int id);
- void SetFirstTime(bool value);
- bool GetFirstTime();
- void InversLstPoints();
+ void SetReferencePoint(std::vector<double> ppoint);
+ std::vector<double> GetReferencePoint();
+ void SetImage(vtkImageData *image);
+ std::string CleanSpaces(std::string ss);
+ vtkImageData* GetImage();
+ void SetRadio(double radio);
+ double GetRadio();
+ int RenamePoint(std::string label);
+ void ErasePoint(int id);
+ void SetFirstTime(bool value);
+ bool GetFirstTime();
+ void InversLstPoints();
private:
- std::vector<int> lstPointsX;
- std::vector<int> lstPointsY;
- std::vector<int> lstPointsZ;
+ std::vector<double> lstPointsX;
+ std::vector<double> lstPointsY;
+ std::vector<double> lstPointsZ;
std::vector<std::string> lstLabels;
- std::vector<int> mReferencePoint;
+ std::vector<double> mReferencePoint;
double mradio;
vtkImageData *mimage;
bool firsttime;
void ViewShowNPoints::RefreshPoint(int id)
{
double spc[3];
- int x,y,z;
+ double x,y,z;
GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
GetModelShowNPoints()->GetImage()->GetSpacing(spc);
std::string label = GetModelShowNPoints()->GetIdLabel(id);
//------------------------------------------------------------------------
-void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
+void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
{
GetModelShowNPoints()->AddPoint(x,y,z, label );
// EED 2022-05-19
}
//------------------------------------------------------------------------
-void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
+void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
{
// EED 2022-05-19
//if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
{
return;
}
- std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
+ std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
if (point.size()==3)
{
InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
{
return;
}
- std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
+ std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
if (point.size()==3)
{
AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
}
//------------------------------------------------------------------------
-void WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
+void WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
{
GetModelShowNPoints()->SetReferencePoint(point);
int i,size=lstModelShowNPoints.size();
}
//------------------------------------------------------------------------
-void WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX, std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
+void WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels )
{
// EED 2022-05-19
//if (this->renderer==NULL)
sizeY = (int)initLstPointsY.size();
sizeZ = (int)initLstPointsZ.size();
sizeLabels = (int)initLstLabels.size();
- int x,y,z;
+ double x,y,z;
std::string label;
if ( (sizeX==sizeY) && (sizeX==sizeZ) )
{
//------------------------------------------------------------------------
void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
{
- int x,y,z;
+ double x,y,z;
lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
pPoint[0] = x;
pPoint[1] = y;
void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
{
if(idCol >= 0 && idCol < lstModelShowNPoints.size())
+ {
lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
+ lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
+ }
else{
printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
}
}
//------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsX()
+std::vector<double> WidgetShowNPoints::GetLstPointsX()
{
if (mtype!=4)
{
return GetModelShowNPoints()->GetLstPointsX();
} else {
- std::vector<int> lst;
+ std::vector<double> lst;
int iP,s;
int iG,sG=lstModelShowNPoints.size();
for (iG=0 ; iG<sG ; iG++)
{
- std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
+ std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
s = lstTmp.size();
for (iP=0 ; iP<s ; iP++)
{
}
//------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsY()
+std::vector<double> WidgetShowNPoints::GetLstPointsY()
{
if (mtype!=4)
{
return GetModelShowNPoints()->GetLstPointsY();
} else {
- std::vector<int> lst;
+ std::vector<double> lst;
int iP,s;
int iG,sG=lstModelShowNPoints.size();
for (iG=0 ; iG<sG ; iG++)
{
- std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
+ std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
s = lstTmp.size();
for (iP=0 ; iP<s ; iP++)
{
}
//------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsZ()
+std::vector<double> WidgetShowNPoints::GetLstPointsZ()
{
if (mtype!=4)
{
return GetModelShowNPoints()->GetLstPointsZ();
} else {
- std::vector<int> lst;
+ std::vector<double> lst;
int iP,s;
int iG,sG=lstModelShowNPoints.size();
for (iG=0 ; iG<sG ; iG++)
{
- std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
+ std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
s = lstTmp.size();
for (iP=0 ; iP<s ; iP++)
{
void SetRadio(double radio);
void SetImage(vtkImageData *image);
void SetRenderer(vtkRenderer *renderer);
- void SetReferencePoint(std::vector<int> point);
+ void SetReferencePoint(std::vector<double> point);
- void AddPoint(int x, int y, int z, std::string label);
+ void AddPoint(double x, double y, double z, std::string label);
void OnInsertPoint_();
- void InsertPoint(int x, int y, int z, std::string label);//CFT
+ void InsertPoint(double x, double y, double z, std::string label);//CFT
int GetLstModelShowNPointsSize();
ModelShowNPoints* GetModelShowNPoints();
ViewShowNPoints* GetViewShowNPoints();
- void SetInitLstPoints( std::vector<int> initLstPointsX, std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels );
+ void SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels );
void SetType(int type);
int GetType();
virtual void SetOutputBox();
void ErasePoint(int id);
- std::vector<int> GetLstPointsX();
- std::vector<int> GetLstPointsY();
- std::vector<int> GetLstPointsZ();
+ std::vector<double> GetLstPointsX();
+ std::vector<double> GetLstPointsY();
+ std::vector<double> GetLstPointsZ();
std::vector<std::string> GetLstLabels();
std::vector<int> GetLstIndexs();