1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
29 #include "bbmaracasvisuContourToControlPoints.h"
30 #include "bbcreaMaracasVisuPackage.h"
31 namespace bbcreaMaracasVisu
34 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourToControlPoints)
35 //BBTK_USER_BLACK_BOX_IMPLEMENTATION(ContourToControlPoints,bbtk::AtomicBlackBox);
36 BBTK_BLACK_BOX_IMPLEMENTATION(ContourToControlPoints,bbtk::AtomicBlackBox);
38 //------------------------------------------------------------
39 void ContourToControlPoints::Process()
41 if ( bbGetInputSampling() >= 3.0 )
46 _ext2D->SetContour( bbGetInputInContourX(),bbGetInputInContourY(),bbGetInputInContourZ() );
47 _ext2D->SetSamplingControlPoints( bbGetInputSampling() );
48 _ext2D->GetSamplingControlPoints( &OutContourX,&OutContourY,&OutContourZ );
50 if(bbGetInputSampling() == 2.0)
55 _ext2D->SetContour( bbGetInputInContourX(),bbGetInputInContourY(),bbGetInputInContourZ() );
56 _ext2D->GetControlPoints( &OutContourX,&OutContourY,&OutContourZ );
59 //Liberates the memory from the VTK's objects. Always must do that!!
60 if ( bbGetInputLoadContour()== 1 )
71 fd = fopen("C:/bbtk_JS/data/SavedContours.txt","r");
72 _propgdata->ReadKeyContour( fd );
74 _propgdata->GetKeyContours(&KeyContourX,&KeyContourY,&KeyContourZ,&KeySizes);
75 if(KeySizes.size() == 1)
78 // _imagedata = _propgdata->method_RBF(bbGetInputRadRBF(),&KeyContourX,&KeyContourY,&KeyContourZ);
80 if(KeySizes.size() >= 2)
83 //_imagedata = _propgdata->method_RBF_3D(bbGetInputRadRBF(),&KeyContourX,&KeyContourY,&KeyContourZ);
84 // _imagedata = _propgdata->method_RBF_3D_ThinPlate(bbGetInputRadRBF(),&KeyContourX,&KeyContourY,&KeyContourZ);
87 if ( bbGetInputLoadContour()== 2 )
94 fd = fopen("C:/bbtk_JS/data/SavedManualPoints.txt","r");
95 _propgdata->ReadKeyContour( fd );
97 _propgdata->GetKeyContours(&KeyContourX,&KeyContourY,&KeyContourZ,&KeySizes);
98 if(KeySizes.size() == 1)
101 // _imagedata = _propgdata->method_RBF(bbGetInputRadRBF(),&KeyContourX,&KeyContourY,&KeyContourZ);
103 if(KeySizes.size() >= 2)
106 //_imagedata = _propgdata->method_RBF_3D(bbGetInputRadRBF(),&KeyContourX,&KeyContourY,&KeyContourZ);
107 // _imagedata = _propgdata->method_RBF_3D_ThinPlate(bbGetInputRadRBF(),&KeyContourX,&KeyContourY,&KeyContourZ);
111 if ( bbGetInputLoadContour()== 3 )
113 if (_imagedata!=NULL)
115 _imagedata->Delete();
117 vtkImageData *itemp = vtkImageData::New();
118 _contprop->appendContour();
119 _contprop->setInterpolationNumber(300);
120 itemp = _contprop->GetKeyContours(&KeyContourX,&KeyContourY,&KeyContourZ,&KeySizes);
121 if(KeySizes.size() == 1)
124 if(KeySizes.size() >= 2)
128 _contprop->resetAppend();
129 _contprop->appendContour(&KeyContourX,&KeyContourY,&KeyContourZ);
130 //_contprop->GetContour(bbGetInputSlice(),&OutContourX,&OutContourY,&OutContourZ);
131 _contprop->GetControlPoints(bbGetInputSlice(),&OutContourX,&OutContourY,&OutContourZ);
132 printf("\n Size OutContourX = %d",(int)(OutContourX.size()));
136 bbSetOutputControlPointX( &OutContourX );
137 bbSetOutputControlPointY( &OutContourY );
138 bbSetOutputControlPointZ( &OutContourZ );
139 bbSetOutputImagePropg( _imagedata );
143 //------------------------------------------------------------
144 void ContourToControlPoints::bbUserSetDefaultValues()
146 bbSetInputSampling(5.0);
148 bbSetInputInContourX(NULL);
149 bbSetInputInContourY(NULL);
150 bbSetInputInContourZ(NULL);
151 bbSetInputRadRBF(1000.0);
153 bbSetInputLoadContour(0);
165 //-----------------------------------------------------------------
166 void ContourToControlPoints::bbUserInitializeProcessing()
168 _contprop = new ContourPropagation();
169 _propgdata = new PropContour();
170 _imagedata = vtkImageData::New();
171 _ext2D = new ExtractControlPoints2D();
174 //-----------------------------------------------------------------
175 void ContourToControlPoints::bbUserFinalizeProcessing()
177 if (_contprop!=NULL) delete _contprop;
178 if (_propgdata!=NULL) delete _propgdata;
179 if (_imagedata!=NULL) _imagedata->Delete();
180 if (_ext2D!=NULL) delete _ext2D;
188 //-----------------------------------------------------------------
193 // EO namespace bbcreaMaracasVisu