]> Creatis software - creaMaracasVisu.git/commitdiff
#3266 creaMaracasVisu Feature New Normal - ManualContour_Box by segments
authorEduardo DAVILA <davila@localhost.localdomain>
Tue, 25 Jun 2019 08:57:04 +0000 (10:57 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Tue, 25 Jun 2019 08:57:04 +0000 (10:57 +0200)
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h
bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx

index d9e1663ec76a4af65ea123c3acff1b91d625ca41..08a6fa7abd55893dafe7eb6ad8f7f8e18ce708a9 100644 (file)
@@ -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<double> *lstInX,std::vector<double> *lstInY, std::vector<double> *lstInZ,
+                       std::vector<double> *lstOutX,std::vector<double> *lstOutY, std::vector<double> *lstOutZ,
+                       std::vector<int>        *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;i<size;i++)
+       {
+               m->AddPoint( (*lstInX)[i] , (*lstInY)[i] , (*lstInZ)[i] );
+       } // for
+       m->UpdateSpline();
+       int sizeContour = bbGetInputNbPoints();
+       for (i=0;i<sizeContour;i++)
+       {
+               m->GetSpline_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 = " <<bbGetOutputOut() << std::endl;
-       
-       creaContoursFactory f;
-       manualContourModel      *m;
-       std::vector<double> lstX;
-       std::vector<double> lstY;
-       std::vector<double> 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<size;i++)
+
+       std::vector<double> lstInX=bbGetInputLstControlPointsX();
+       std::vector<double> lstInY=bbGetInputLstControlPointsY();
+       std::vector<double> 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<int>        lstIndexsIn=bbGetInputLstIndexsIn();
+       std::vector<int>        lstIndexsOut;
+       std::vector<double> lstOutX;
+       std::vector<double> lstOutY;
+       std::vector<double> 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;i<size;i++)
        {
-               m->GetSpline_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);  
 
 }
 //===== 
index d1176c0146aac10353daa9bb20e835053fb7bcc0..2f79cc1eb6e484626f23521a1722fd3f4e19de1a 100644 (file)
@@ -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<int>);
+
   BBTK_DECLARE_INPUT(LstControlPointsX,std::vector<double>);
   BBTK_DECLARE_INPUT(LstControlPointsY,std::vector<double>);
   BBTK_DECLARE_INPUT(LstControlPointsZ,std::vector<double>);
+
   BBTK_DECLARE_OUTPUT(LstContourPointsX,std::vector<double>);
   BBTK_DECLARE_OUTPUT(LstContourPointsY,std::vector<double>);
   BBTK_DECLARE_OUTPUT(LstContourPointsZ,std::vector<double>);
+  BBTK_DECLARE_OUTPUT(LstIndexsOut,std::vector<int>);
   BBTK_PROCESS(Process);
   void Process();
+
+
+  void ProcessBySegment(       
+                       int Type, 
+                       int &iGeneral, int sizeSegment,
+                       std::vector<double> *lstInX,std::vector<double> *lstInY, std::vector<double> *lstInZ,
+                       std::vector<double> *lstOutX,std::vector<double> *lstOutY, std::vector<double> *lstOutZ,
+                       std::vector<int>        *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<int>,"");
+
   BBTK_INPUT(ManualContourModel_Box,LstControlPointsX,"List of control points",std::vector<double>,"");
   BBTK_INPUT(ManualContourModel_Box,LstControlPointsY,"List of control points",std::vector<double>,"");
   BBTK_INPUT(ManualContourModel_Box,LstControlPointsZ,"List of control points",std::vector<double>,"");
@@ -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<double>,"");
   BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsY,"List of points in the contour",std::vector<double>,"");
   BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsZ,"List of points in the contour",std::vector<double>,"");
+  BBTK_OUTPUT(ManualContourModel_Box,LstIndexsOut,"Lst number of points by segment",std::vector<int>,"");
 
 BBTK_END_DESCRIBE_BLACK_BOX(ManualContourModel_Box);
 //===== 
index f56b4164065fab81ce73a0ff4544765802d9bd05..45ec0b7d52bf1de570da9ba36a9a9a416a08b0c8 100644 (file)
@@ -192,7 +192,12 @@ void DrawAxisTree3D::Process()
 {
 
        int iGeneral=0;
-       int iAxis,sizeLstAxis=bbGetInputlstIndexs().size();
+       std::vector<int> 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<sizeLstAxis ; iAxis++)
         {
-            numPoints = bbGetInputlstIndexs()[iAxis];
+            numPoints = lstIndexs[iAxis];
             DrawOneAxis(iGeneral,numPoints,iAxis);
             iGeneral = iGeneral+numPoints;