FIN_COMPLEX_PORT
COMPLEX_PORT
ExportIsActive_concatstring_tool
--495.718682:-76.702206:-900.000000
+-550.600502:-76.318417:-900.000000
FIN_COMPLEX_PORT
COMPLEXINPUTS:9
COMPLEX_PORT
meshmanagermodel
-131.800179:136.578564:-900.000000
FIN_COMPLEX_PORT
-BOXES:90
+BOXES:98
BOX
wx:LayoutLine:Box08
ISEXEC:FALSE
BOX
creaMaracasVisu:wxVtkBaseView_Info:Box96
ISEXEC:FALSE
--287.507139:74.319532:-900.000000
--260.227139:71.819532:-900.000000
+-282.583529:75.895087:-900.000000
+-255.303529:73.395087:-900.000000
FIN_BOX
BOX
creaVtk:MeshManager_tool:Box48
BOX
creaMaracasVisu:wxVtkBaseView_info_tool:Box91
ISEXEC:FALSE
--295.971226:67.391116:-900.000000
--272.891226:64.891116:-900.000000
+-301.387197:67.588060:-900.000000
+-278.307197:65.088060:-900.000000
PORT
Type:"0"
FIN_BOX
PORT
Tool:"20"
FIN_BOX
-CONNECTIONS:171
+BOX
+creaMaracasVisu:SetPosition:Box142
+ISEXEC:FALSE
+-486.165273:-86.007669:-900.000000
+-464.395273:-88.507669:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:SetPosition:Box143
+ISEXEC:FALSE
+-458.925237:-86.103993:-900.000000
+-437.155237:-88.603993:-900.000000
+FIN_BOX
+BOX
+std:MathOperationVector:Box144
+ISEXEC:FALSE
+-453.769576:-74.337147:-900.000000
+-429.249576:-76.837147:-900.000000
+PORT
+Type:"3"
+FIN_BOX
+BOX
+std:MathOperationVector:Box145
+ISEXEC:FALSE
+-482.408042:-69.518814:-900.000000
+-457.888042:-72.018814:-900.000000
+PORT
+Type:"3"
+FIN_BOX
+BOX
+creaVtk:PointPickerNearest:Box148
+ISEXEC:FALSE
+-516.890064:-75.470080:-900.000000
+-494.330064:-77.970080:-900.000000
+FIN_BOX
+BOX
+creaVtk:PlaneWidget_Base:Box154
+ISEXEC:FALSE
+-534.858110:-91.209728:-900.000000
+-512.338110:-93.709728:-900.000000
+PORT
+Type:"2"
+FIN_BOX
+BOX
+std:MultipleInputs:Box150
+ISEXEC:FALSE
+-513.551344:-104.677172:-900.000000
+-491.471344:-107.177172:-900.000000
+FIN_BOX
+BOX
+creaVtk:PlaneWidget_Base:Box151
+ISEXEC:FALSE
+-512.258536:-92.741365:-900.000000
+-489.738536:-95.241365:-900.000000
+PORT
+Type:"3"
+FIN_BOX
+CONNECTIONS:185
CONNECTION
Box08:Widget:widget:widget
NumberOfControlPoints:0
Box58:BoxChange:Box89:BoxExecute
NumberOfControlPoints:0
CONNECTION
-Box122:Out:Box134:StringParam
+Box122:Out:Box134:DoubleParams
+NumberOfControlPoints:0
+CONNECTION
+Box138:BoxChange:Box143:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box96:wxVtkBaseView:Box143:wxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box96:wxVtkBaseView:Box142:wxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box138:Out:Box144:In0
+NumberOfControlPoints:0
+CONNECTION
+Box83:Spacing:Box144:In1
+NumberOfControlPoints:0
+CONNECTION
+Box144:Out:Box143:Point
+NumberOfControlPoints:0
+CONNECTION
+Box137:Out:Box145:In0
+NumberOfControlPoints:0
+CONNECTION
+Box83:Spacing:Box145:In1
+NumberOfControlPoints:0
+CONNECTION
+Box145:Out:Box142:Point
+NumberOfControlPoints:0
+CONNECTION
+Box154:BoxChange:Box150:In1
+NumberOfControlPoints:0
+CONNECTION
+Box148:Normal:Box154:ParamVector
+NumberOfControlPoints:0
+CONNECTION
+Box151:BoxChange:Box150:In3
+NumberOfControlPoints:0
+CONNECTION
+Box148:PointOut:Box151:ParamVector
+NumberOfControlPoints:0
+CONNECTION
+Box137:BoxChange:Box142:BoxExecute
NumberOfControlPoints:0
APP_END
set Box138.BoxProcessMode "Manual"
set Box138.Tool "20"
+new creaMaracasVisu:SetPosition Box142
+
+new creaMaracasVisu:SetPosition Box143
+
+new std:MathOperationVector Box144
+ set Box144.Type "3"
+
+new std:MathOperationVector Box145
+ set Box145.Type "3"
+
+new creaVtk:PointPickerNearest Box148
+
+new creaVtk:PlaneWidget_Base Box154
+ set Box154.Type "2"
+
+new std:MultipleInputs Box150
+
+new creaVtk:PlaneWidget_Base Box151
+ set Box151.Type "3"
+
connect Box66.Out Box11.Renderer
connect Box66.Out Box37.render
connect Box95.Out Box58.Origin
connect Box58.BoxChange Box61.In2
connect Box58.BoxChange Box89.BoxExecute
-connect Box122.Out Box134.StringParam
+connect Box122.Out Box134.DoubleParams
+connect Box138.BoxChange Box143.BoxExecute
+connect Box96.wxVtkBaseView Box143.wxVtkBaseView
+connect Box96.wxVtkBaseView Box142.wxVtkBaseView
+connect Box138.Out Box144.In0
+connect Box83.Spacing Box144.In1
+connect Box144.Out Box143.Point
+connect Box137.Out Box145.In0
+connect Box83.Spacing Box145.In1
+connect Box145.Out Box142.Point
+connect Box154.BoxChange Box150.In1
+connect Box148.Normal Box154.ParamVector
+connect Box151.BoxChange Box150.In3
+connect Box148.PointOut Box151.ParamVector
+connect Box137.BoxChange Box142.BoxExecute
# Complex input ports
input mesh Box67.In " "
# ----------------------------------
# - BBTKGEditor v 1.5 BBG BlackBox Diagram file
-# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg
+# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg
# ----------------------------------
APP_START
ISEXEC:FALSE
-271.434991:53.686536:-900.000000
-248.999991:51.186536:-900.000000
+PORT
+Params:"156 276 97"
FIN_BOX
BOX
vtk:ImageVtkProperties:Box68
-265.790737:67.872984:-900.000000
-237.750737:65.372984:-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 12 13"
PORT
-In1:"1 5 10 20 30 40 50 0 100 110 205 210 240"
+In1:"1 5 10 20 30 40 50 0 100 110 205 210 240 400"
PORT
Type:"2"
FIN_BOX
In0:"Tool - Inverse Normals"
PORT
In1:"Tool - Join start and end points to current spline"
+PORT
+In2:"Tool - Separate and order contours around axis"
FIN_BOX
BOX
wx:LayoutLine:Box121
# ----------------------------------
# - BBTKGEditor v 1.5 BBS BlackBox Script (Complex Box)
-# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs
+# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs
# ----------------------------------
include std
set Box58.In9 "Tool - Create Volume Surface from 3 or 4 points (use Close Spline 2 - Close Surface Off)"
new creaMaracasVisu:ShowNPoints_Tools Box60
+ set Box60.Params "156 276 97"
new vtk:ImageVtkProperties Box68
set Box99.In0 "Auto Add Points (Start/Stop)"
new std:VectorFilterString Box100
- set Box100.In0 "0 1 2 3 4 5 6 7 8 9 10 11 12"
- set Box100.In1 "1 5 10 20 30 40 50 0 100 110 205 210 240"
+ set Box100.In0 "0 1 2 3 4 5 6 7 8 9 10 11 12 13"
+ set Box100.In1 "1 5 10 20 30 40 50 0 100 110 205 210 240 400"
set Box100.Type "2"
new std:ConcatStrings Box101
new std:AddStringToVector Box115
set Box115.In0 "Tool - Inverse Normals"
set Box115.In1 "Tool - Join start and end points to current spline"
+ set Box115.In2 "Tool - Separate and order contours around axis"
new wx:LayoutLine Box121
set Box121.Orientation "V"
wsp->SetAuxMesh(bbGetInputMesh(), bbGetInputSpacing(), bbGetInputParams() );
}
+void ShowNPoints_Tools::SeparateSplines()
+{
+ WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+ if((wsp->GetLstModelShowNPointsSize() > 0) && (bbGetInputParams().size() == 3))
+ {
+ std::vector<double> refPoint = bbGetInputParams();
+ std::vector<double> pointsX, pointsY, pointsZ;
+ std::vector<std::vector<std::vector<double>>> newGroups;
+ std::vector<std::vector<double>> planesNorm;
+
+ double rotAxis[3] = {0,0,1};
+
+ double vector1[3], vector2[3], planeNormal[3], rotatedNormal[3], axisPoint[3], refPlaneNorm[3];
+ int idPoint2, idPoint3;
+
+ int numGroups = wsp->GetLstModelShowNPointsSize();
+ for(int i = 0; i < numGroups; i++){
+ pointsX = wsp->GetModelShowNPoints(i)->GetLstPointsX();
+ pointsY = wsp->GetModelShowNPoints(i)->GetLstPointsY();
+ pointsZ = wsp->GetModelShowNPoints(i)->GetLstPointsZ();
+
+ idPoint2 = ((int)pointsX.size()/3)-1;
+ idPoint3 = idPoint2*2;
+
+ vector1[0] = pointsX[idPoint2]-refPoint[0];
+ vector1[1] = pointsY[idPoint2]-refPoint[1];
+ vector1[2] = pointsZ[idPoint2]-refPoint[2];
+
+ vector2[0] = pointsX[idPoint3]-refPoint[0];
+ vector2[1] = pointsY[idPoint3]-refPoint[1];
+ vector2[2] = pointsZ[idPoint3]-refPoint[2];
+
+ vtkMath::Cross(vector1, vector2, planeNormal);
+ vtkMath::Normalize(planeNormal);
+ vtkMath::Cross(planeNormal, rotAxis, rotatedNormal);
+ vtkMath::Normalize(rotatedNormal);
+
+ if(i == 0){
+ std::copy(std::begin(planeNormal), std::end(planeNormal), std::begin(refPlaneNorm));
+ }
+
+ std::vector<std::vector<double>> pointsOver, pointsUnder, pointsOn;
+ std::vector<double> point(3);
+ for(int j = 0; j < pointsX.size(); j++){
+ point[0] = pointsX[j];
+ point[1] = pointsY[j];
+ point[2] = pointsZ[j];
+ vtkMath::Subtract(point.data(), refPoint.data(), vector1);
+ if(vtkMath::Dot(vector1, rotatedNormal) > 0){
+ pointsOver.push_back(point);
+ }
+ else if (vtkMath::Dot(vector1, rotatedNormal) < 0){
+ pointsUnder.push_back(point);
+ }
+ //else{
+ // pointsOn.push_back(j);
+ //}
+ }
+
+ std::vector<double> normalToSave(std::begin(planeNormal), std::end(planeNormal));
+ if(!pointsOver.empty()){
+ newGroups.push_back(pointsOver);
+ planesNorm.push_back(normalToSave);
+ }
+ if(!pointsUnder.empty()){
+ std::reverse(pointsUnder.begin(), pointsUnder.end());
+ newGroups.push_back(pointsUnder);
+ vtkMath::MultiplyScalar(planeNormal, -1);
+ normalToSave[0] = planeNormal[0]; normalToSave[1] = planeNormal[1]; normalToSave[2] = planeNormal[2];
+ planesNorm.push_back(normalToSave);
+ }
+
+
+ }
+
+ auto comp = [&](int id1,int id2)-> bool {
+ //double dot = vtkMath::Dot(planesNorm[id1].data(), refPlaneNorm);
+ //double det = vtkMath::Determinant3x3(planesNorm[id1].data(), refPlaneNorm, rotAxis);
+ //double angle1 = atan2(det, dot);
+ double angle1 = vtkMath::SignedAngleBetweenVectors(planesNorm[id1].data(), refPlaneNorm, rotAxis);
+ if(angle1 < 0) angle1 += 2*vtkMath::Pi();
+ double angle2 = vtkMath::SignedAngleBetweenVectors(planesNorm[id2].data(), refPlaneNorm, rotAxis);
+ if(angle2 < 0) angle2 += 2*vtkMath::Pi();
+ return angle1 < angle2;
+ };
+
+ std::vector<int> indexVect((int)newGroups.size());
+ std::iota(std::begin(indexVect), std::end(indexVect), 0);
+ std::sort(indexVect.begin(), indexVect.end(), comp);
+
+ wsp->ResetCollections_();
+ for(int i = 0; i < newGroups.size(); i++){
+ std::vector<std::vector<double>> group = newGroups[indexVect[i]];
+ for(int j = 0; j < group.size(); j++){
+ std::vector<double> point = group[j];
+ wsp->AddPoint(point[0] ,point[1], point[2],"");
+ }
+ if(i < newGroups.size()-1){
+ wsp->InsertCollectionAfter_();
+ }
+ }
+ wsp->SetOutputBox();
+ wsp->UndoRedo_SaveCollection();
+ }
+}
+
//=====
// 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)
//=====
{
ExpandPatch();
} // if Type
+ if(bbGetInputType()==400)
+ {
+ SeparateSplines();
+ } // if Type
} // if bbGetInputWidgetShowNPoints
}
//=====
#include "bbcreaMaracasVisu_EXPORT.h"
#include "bbtkAtomicBlackBox.h"
#include "iostream"
+#include <numeric>
#include "WidgetShowNPoints.h"
void MovePointInNormal();
void JoinPoints();
void SetMesh();
+ void SeparateSplines();
//=====
// 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 200:Tool 3 or 4 points to patch surface - Create Mesh (based on 1 group and 3 or 4 points) 205:Tool 3 or 4 points to volume surface - Create Mesh (based on 1 group and 3 or 4 points) 210: Invert points 220: Move patch center (param is the step ex [-1] or [1]) 230: Move point in normal of surface (Params [-1] or [1]) 235: ChangeCurrentPoint (Params [-1] or [1]) 240: Join all start-end points to the start-end points on selected spline 250: Set Mesh SPC (Params: [0]:Patch [1]:CloseSpline1 [2]:CloseSpline2) 300: Create expanded surface 310: Create wide expanded surface 320: Expand Surface, 330: Widen surface, 340: Expand patch",int,"");
- BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required for 200: normal and direction, 320: centroid and direction, 330: normal and direction, 340: centroid 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 patch surface - Create Mesh (based on 1 group and 3 or 4 points) 205:Tool 3 or 4 points to volume surface - Create Mesh (based on 1 group and 3 or 4 points) 210: Invert points 220: Move patch center (param is the step ex [-1] or [1]) 230: Move point in normal of surface (Params [-1] or [1]) 235: ChangeCurrentPoint (Params [-1] or [1]) 240: Join all start-end points to the start-end points on selected spline 250: Set Mesh SPC (Params: [0]:Patch [1]:CloseSpline1 [2]:CloseSpline2) 300: Create expanded surface 310: Create wide expanded surface 320: Expand Surface, 330: Widen surface, 340: Expand patch, 400: Separate and Order Splines given a rotation origin",int,"");
+ BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required for 200: normal and direction, 320: centroid and direction, 330: normal and direction, 340: centroid and direction, 400: reference point", std::vector<double>,"");
BBTK_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector<double>, "");
// BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,"");