# ----------------------------------
# - 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
meshmanagermodel
-150.374274:130.740991:-900.000000
FIN_COMPLEX_PORT
-BOXES:75
+BOXES:81
BOX
creaMaracasVisu:ShowNPoints:showNpoints
ISEXEC:FALSE
BOX
creaMaracasVisu:ManualContourModel_Box:Box06
ISEXEC:FALSE
-29.075845:30.364799:-900.000000
-53.595845:27.864799:-900.000000
+35.216468:30.364799:-900.000000
+59.736468:27.864799:-900.000000
PORT
DoubleContour:"1"
PORT
BOX
std:MultipleInputs:Box31
ISEXEC:FALSE
-21.957727:-67.075176:-900.000000
-43.927727:-69.575176:-900.000000
+18.992085:-64.219001:-900.000000
+40.962085:-66.719001:-900.000000
FIN_BOX
BOX
creaMaracasVisu:ManualContourModel_Box:Box29
BOX
creaVtk:LinearExtrusionFilter:Box96
ISEXEC:FALSE
-126.330445:-29.439611:-900.000000
-148.840445:-31.939611:-900.000000
+126.138551:-32.318028:-900.000000
+148.648551:-34.818028:-900.000000
FIN_BOX
BOX
creaMaracasVisu:PolyDataToActor_Widget:Box98
PORT
In0:"Auto Add Points (Start/Stop)"
FIN_BOX
-CONNECTIONS:154
+BOX
+creaMaracasVisu:ShowNPoints_Tools:Box120
+ISEXEC:FALSE
+-380.000207:-26.721711:-900.000000
+-357.455207:-29.221711:-900.000000
+PORT
+BoxProcessMode:"Manual"
+PORT
+Type:"220"
+FIN_BOX
+BOX
+wx:CommandButton:Box121
+ISEXEC:FALSE
+-390.668472:-8.967632:-900.000000
+-368.283472:-11.467632:-900.000000
+PORT
+Label:"+"
+FIN_BOX
+BOX
+wx:CommandButton:Box127
+ISEXEC:FALSE
+-322.149651:-11.922729:-900.000000
+-299.764651:-14.422729:-900.000000
+PORT
+Label:"-"
+FIN_BOX
+BOX
+creaMaracasVisu:ShowNPoints_Tools:Box128
+ISEXEC:FALSE
+-328.813882:-27.476919:-900.000000
+-306.268882:-29.976919:-900.000000
+PORT
+BoxProcessMode:"Manual"
+PORT
+Type:"220"
+FIN_BOX
+BOX
+std:ConcatStrings:Box130
+ISEXEC:FALSE
+-378.800018:37.000233:-900.000000
+-356.040018:34.500233:-900.000000
+PORT
+In2:" 1"
+FIN_BOX
+BOX
+std:ConcatStrings:Box131
+ISEXEC:FALSE
+-344.138161:36.747302:-900.000000
+-321.378161:34.247302:-900.000000
+PORT
+In2:" -1"
+FIN_BOX
+CONNECTIONS:168
CONNECTION
Box06:LstContourPointsX:Box04:LstX
NumberOfControlPoints:0
CONNECTION
Box119:Out:Box58:StringVector
NumberOfControlPoints:0
+CONNECTION
+Box68:Spacing:Box120:Spacing
+NumberOfControlPoints:0
+CONNECTION
+showNpoints:WidgetShowNPoints:Box120:WidgetShowNPoints
+NumberOfControlPoints:0
+CONNECTION
+Box121:BoxChange:Box120:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box121:Widget:Box101:Widget5
+NumberOfControlPoints:0
+CONNECTION
+Box127:BoxChange:Box128:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box127:Widget:Box101:Widget6
+NumberOfControlPoints:0
+CONNECTION
+Box68:Spacing:Box128:Spacing
+NumberOfControlPoints:0
+CONNECTION
+showNpoints:WidgetShowNPoints:Box128:WidgetShowNPoints
+NumberOfControlPoints:0
+CONNECTION
+Box60:Out:Box130:In1
+NumberOfControlPoints:0
+CONNECTION
+Box60:Out:Box131:In1
+NumberOfControlPoints:0
+CONNECTION
+Box130:Out:Box120:Params
+NumberOfControlPoints:0
+CONNECTION
+Box131:Out:Box128:Params
+NumberOfControlPoints:0
+CONNECTION
+Box120:BoxChange:Box31:In3
+NumberOfControlPoints:0
+CONNECTION
+Box128:BoxChange:Box31:In5
+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
new std:AddStringToVector Box119
set Box119.In0 "Auto Add Points (Start/Stop)"
+new creaMaracasVisu:ShowNPoints_Tools Box120
+ set Box120.BoxProcessMode "Manual"
+ set Box120.Type "220"
+
+new wx:CommandButton Box121
+ set Box121.Label "+"
+
+new wx:CommandButton Box127
+ set Box127.Label "-"
+
+new creaMaracasVisu:ShowNPoints_Tools Box128
+ set Box128.BoxProcessMode "Manual"
+ set Box128.Type "220"
+
+new std:ConcatStrings Box130
+ set Box130.In2 " 1"
+
+new std:ConcatStrings Box131
+ set Box131.In2 " -1"
+
connect Box06.LstContourPointsX Box04.LstX
connect showNpoints.lstIndexs Box06.LstIndexsIn
connect Box118.Out Box96.ScalarFactor
connect Box118.BoxChange Box103.In3
connect Box119.Out Box58.StringVector
+connect Box68.Spacing Box120.Spacing
+connect showNpoints.WidgetShowNPoints Box120.WidgetShowNPoints
+connect Box121.BoxChange Box120.BoxExecute
+connect Box121.Widget Box101.Widget5
+connect Box127.BoxChange Box128.BoxExecute
+connect Box127.Widget Box101.Widget6
+connect Box68.Spacing Box128.Spacing
+connect showNpoints.WidgetShowNPoints Box128.WidgetShowNPoints
+connect Box60.Out Box130.In1
+connect Box60.Out Box131.In1
+connect Box130.Out Box120.Params
+connect Box131.Out Box128.Params
+connect Box120.BoxChange Box31.In3
+connect Box128.BoxChange Box31.In5
# Complex input ports
input point showNpoints.In " "
void ShowNPoints_Tools::CreatePatch_3points()
{
- printf("PG ShowNPoints_Tools::CreatePatch_3points Entered patch 3 points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+ //printf("PG ShowNPoints_Tools::CreatePatch_3points Entered patch 3 points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
wsp->StopAutoAddPoints();
wsp->StopTrackPoint();
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");
+ //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");
+ //printf("PG ShowNPoints_Tools::CreatePatch_3points Warning patch not apply. Need only one group of 3 points\n");
}
}
// 4. Si el angulo es major de 90 Invertir las normales de la superficie actual
if (angle<90)
{
+ vtkMath::MultiplyScalar(n2, -1);
wsp->InvertLstPoints_();
} // if angle
+ std::vector<double> normalOut(n2, n2 + 3);
+ double norm = vtkMath::Norm(n2);
+ normalOut[0] = normalOut[0]/norm;
+ normalOut[1] = normalOut[1]/norm;
+ normalOut[2] = normalOut[2]/norm;
+ bbSetOutputOut(normalOut);
// --- Finish ---
wsp->SetOutputBox();
wsp->UndoRedo_SaveCollection();
}
+void ShowNPoints_Tools::MovePatchCenter()
+{
+ std::vector<double> params = bbGetInputParams();
+ if(params.size() == 4)
+ {
+ if(params[3] != 1 && params[3] != -1)
+ {
+ printf("PG ShowNPoints_Tools::MovePatchCenter() Warning params are wrong. direction of movement should be 1 or -1\n");
+ return;
+ }
+
+ double centerPoint[3];
+ std::vector<double> normal, modPoint;
+
+ normal.push_back(params[0]);
+ normal.push_back(params[1]);
+ normal.push_back(params[2]);
+ int direction = -params[3];
+
+ WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+ wsp->GetCollectionPoint(1,1, centerPoint);
+ modPoint.push_back(centerPoint[0] + direction*normal[0]);
+ modPoint.push_back(centerPoint[1] + direction*normal[1]);
+ modPoint.push_back(centerPoint[2] + direction*normal[2]);
+
+ wsp->SetCollectionPoint(1, 1, modPoint);
+ wsp->GetViewShowNPoints()->RefreshPoints();
+ }else{
+ printf("PG ShowNPoints_Tools::MovePatchCenter() Warning params are wrong. Need 4: normal x y z and direction of movement (1 or -1)\n");
+ }
+}
//=====
// 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)
{
bbGetInputWidgetShowNPoints()->OnInvertLstPoints_();
} // if Type
+ if(bbGetInputType()==220)
+ {
+ MovePatchCenter();
+ } // if Type
} // if bbGetInputWidgetShowNPoints
}
//=====
BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
BBTK_DECLARE_INPUT(Mesh,vtkPolyData*);
BBTK_DECLARE_INPUT(Type,int);
+ BBTK_DECLARE_INPUT(Params, std::vector<double>);
+ BBTK_DECLARE_OUTPUT(Out, std::vector<double>);
// BBTK_DECLARE_OUTPUT(Out,double);
BBTK_PROCESS(Process);
void Process();
void CreatePatch_4points();
void CreatePatch_Points(std::vector<int> lstX, std::vector<int> lstY, std::vector<int> lstZ);
void NearestPointToMesh( vtkPoints *points, vtkStaticPointLocator *pointLocator, double *spc , double *p , double *pM );
+ void MovePatchCenter();
//=====
// 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_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)",int,"");
+ 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_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector<double>, "");
// BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,"");
BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints_Tools);
//=====
return id;
} // if
}
-
+//------------------------------------------------------------------------
+void ModelShowNPoints::SetPointById(int id, std::vector<double> point)
+{
+ if(id >= 0 && id < lstPointsX.size()){
+ lstPointsX[id] = point[0];
+ lstPointsY[id] = point[1];
+ lstPointsZ[id] = point[2];
+ }
+ else{
+ printf("WidgetShowNPoints::SetPointById Invalid pointid, id is outside range\n");
+ }
+}
//------------------------------------------------------------------------
int ModelShowNPoints::RenamePoint(std::string label)
{
void SetPointId_mReferencePoint(int id);
int IdInsidePoint();
+ void SetPointById(int id, std::vector<double> point);
+
void SetReferencePoint(std::vector<int> ppoint);
std::vector<int> GetReferencePoint();
void SetImage(vtkImageData *image);
pPoint[1] = y;
pPoint[2] = z;
}
-
+//------------------------------------------------------------------------
+void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
+{
+ if(idCol >= 0 && idCol < lstModelShowNPoints.size())
+ lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
+ else{
+ printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
+ }
+}
//------------------------------------------------------------------------
std::vector<int> WidgetShowNPoints::GetLstPointsX()
{
void OnResetCollections_();
void OnResetCollections(wxCommandEvent &event);
void GetCollectionPoint(int idCol,int idPoint, double *pPoint);
+
+ void SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint);
void OnUndo(wxCommandEvent &event);
void OnRedo(wxCommandEvent &event);