From: Eduardo DAVILA Date: Tue, 25 Jun 2019 08:57:04 +0000 (+0200) Subject: #3266 creaMaracasVisu Feature New Normal - ManualContour_Box by segments X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=de808c527360eb85024fa1de346df719d70e9bca;p=creaMaracasVisu.git #3266 creaMaracasVisu Feature New Normal - ManualContour_Box by segments --- diff --git a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx index d9e1663..08a6fa7 100644 --- a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx @@ -15,9 +15,44 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualContourModel_Box,bbtk::AtomicBlackBox); //===== // 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) //===== -void ManualContourModel_Box::Process() + + +void ManualContourModel_Box::ProcessBySegment( + int Type, + int &iGeneral, int sizeSegment, + std::vector *lstInX,std::vector *lstInY, std::vector *lstInZ, + std::vector *lstOutX,std::vector *lstOutY, std::vector *lstOutZ, + std::vector *lstIndexsOut ) { + creaContoursFactory f; + manualContourModel *m; + int i,size=iGeneral+sizeSegment; + + double x,y,z; + + m = (manualContourModel*)f.getContourModel( bbGetInputType() ); + m->SetNumberOfPointsSpline( bbGetInputNbPoints() ); + m->SetCloseContour( bbGetInputOpenClose() ); + for (i=iGeneral;iAddPoint( (*lstInX)[i] , (*lstInY)[i] , (*lstInZ)[i] ); + } // for + m->UpdateSpline(); + int sizeContour = bbGetInputNbPoints(); + for (i=0;iGetSpline_i_Point(i,&x,&y,&z); + lstOutX->push_back(x); + lstOutY->push_back(y); + lstOutZ->push_back(z); + } // for + iGeneral=iGeneral+sizeSegment; + lstIndexsOut->push_back( sizeContour ); + delete m; +} +void ManualContourModel_Box::Process() +{ // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -32,38 +67,43 @@ void ManualContourModel_Box::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " < lstX; - std::vector lstY; - std::vector lstZ; - int i,size; - double x,y,z; - m = (manualContourModel*)f.getContourModel( bbGetInputType() ); - m->SetNumberOfPointsSpline( bbGetInputNbPoints() ); - m->SetCloseContour( bbGetInputOpenClose() ); - size = bbGetInputLstControlPointsX().size(); - for (i=0;i lstInX=bbGetInputLstControlPointsX(); + std::vector lstInY=bbGetInputLstControlPointsY(); + std::vector lstInZ=bbGetInputLstControlPointsZ(); + + if ( (lstInX.size()!=lstInY.size()) || (lstInY.size()!=lstInZ.size()) ) + { + printf("Warnning !! .. ManualContourModel_Box: The list X Y Z, no have the same number of elements \n"); + return; + } + + std::vector lstIndexsIn=bbGetInputLstIndexsIn(); + std::vector lstIndexsOut; + std::vector lstOutX; + std::vector lstOutY; + std::vector lstOutZ; + + if (bbGetInputLstIndexsIn().size()==0) { -// m->InsertPoint( bbGetInputLstControlPointsX()[i] , bbGetInputLstControlPointsY()[i] , bbGetInputLstControlPointsZ()[i] ); - m->AddPoint( bbGetInputLstControlPointsX()[i] , bbGetInputLstControlPointsY()[i] , bbGetInputLstControlPointsZ()[i] ); - } // for - m->UpdateSpline(); - size = bbGetInputNbPoints(); + lstIndexsIn.push_back( lstInX.size() ); + } + + int i,size=lstIndexsIn.size(); + int iGeneral=0; for (i=0;iGetSpline_i_Point(i,&x,&y,&z); - lstX.push_back(x); - lstY.push_back(y); - lstZ.push_back(z); + ProcessBySegment( bbGetInputType() , + iGeneral, lstIndexsIn[i] , + &lstInX,&lstInY,&lstInZ, + &lstOutX,&lstOutY,&lstOutZ, + &lstIndexsOut); } // for - bbSetOutputLstContourPointsX(lstX); - bbSetOutputLstContourPointsY(lstY); - bbSetOutputLstContourPointsZ(lstZ); - - delete m; + bbSetOutputLstContourPointsX(lstOutX); + bbSetOutputLstContourPointsY(lstOutY); + bbSetOutputLstContourPointsZ(lstOutZ); + bbSetOutputLstIndexsOut(lstIndexsOut); } //===== diff --git a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h index d1176c0..2f79cc1 100644 --- a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h +++ b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h @@ -21,14 +21,29 @@ class bbcreaMaracasVisu_EXPORT ManualContourModel_Box BBTK_DECLARE_INPUT(Type,int); BBTK_DECLARE_INPUT(OpenClose,bool); BBTK_DECLARE_INPUT(NbPoints,int); + + BBTK_DECLARE_INPUT(LstIndexsIn,std::vector); + BBTK_DECLARE_INPUT(LstControlPointsX,std::vector); BBTK_DECLARE_INPUT(LstControlPointsY,std::vector); BBTK_DECLARE_INPUT(LstControlPointsZ,std::vector); + BBTK_DECLARE_OUTPUT(LstContourPointsX,std::vector); BBTK_DECLARE_OUTPUT(LstContourPointsY,std::vector); BBTK_DECLARE_OUTPUT(LstContourPointsZ,std::vector); + BBTK_DECLARE_OUTPUT(LstIndexsOut,std::vector); BBTK_PROCESS(Process); void Process(); + + + void ProcessBySegment( + int Type, + int &iGeneral, int sizeSegment, + std::vector *lstInX,std::vector *lstInY, std::vector *lstInZ, + std::vector *lstOutX,std::vector *lstOutY, std::vector *lstOutZ, + std::vector *lstIndexsOut ); + + //===== // 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) //===== @@ -43,6 +58,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualContourModel_Box,bbtk::AtomicBlackBox); BBTK_INPUT(ManualContourModel_Box,Type,"(1 default) 1=spline, 2=rectangle, 3=circle, 4=bullEye, 6=Line, 7=points, 8=rotationTool, 10=polygon, 12=Spline3D",int,""); BBTK_INPUT(ManualContourModel_Box,OpenClose,"(false default) false=open, true=close",bool,""); BBTK_INPUT(ManualContourModel_Box,NbPoints,"(100 default) Number of points int the spline",int,""); + BBTK_INPUT(ManualContourModel_Box,LstIndexsIn,"Lst number of points by segment",std::vector,""); + BBTK_INPUT(ManualContourModel_Box,LstControlPointsX,"List of control points",std::vector,""); BBTK_INPUT(ManualContourModel_Box,LstControlPointsY,"List of control points",std::vector,""); BBTK_INPUT(ManualContourModel_Box,LstControlPointsZ,"List of control points",std::vector,""); @@ -50,6 +67,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualContourModel_Box,bbtk::AtomicBlackBox); BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsX,"List of points in the contour",std::vector,""); BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsY,"List of points in the contour",std::vector,""); BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsZ,"List of points in the contour",std::vector,""); + BBTK_OUTPUT(ManualContourModel_Box,LstIndexsOut,"Lst number of points by segment",std::vector,""); BBTK_END_DESCRIBE_BLACK_BOX(ManualContourModel_Box); //===== diff --git a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx index f56b416..45ec0b7 100644 --- a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx +++ b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx @@ -192,7 +192,12 @@ void DrawAxisTree3D::Process() { int iGeneral=0; - int iAxis,sizeLstAxis=bbGetInputlstIndexs().size(); + std::vector lstIndexs = bbGetInputlstIndexs(); + if ( bbGetInputlstIndexs().size()==0 ) + { + lstIndexs.push_back( bbGetInputlstPointX().size() ); + } // if + int iAxis,sizeLstAxis=lstIndexs.size(); int iActor,sizeActors = vecVtkActors.size(); int numPoints; @@ -217,7 +222,7 @@ void DrawAxisTree3D::Process() for ( iAxis=0 ; iAxis