7 #include "fwTest/generator/Object.hpp" 9 #include "fwTest/generator/Image.hpp" 10 #include "fwTest/generator/Mesh.hpp" 11 #include "fwTest/generator/SeriesDB.hpp" 13 #include <fwData/Integer.hpp> 14 #include <fwData/Plane.hpp> 15 #include <fwData/ProcessObject.hpp> 16 #include <fwData/Resection.hpp> 17 #include <fwData/ResectionDB.hpp> 18 #include <fwData/String.hpp> 20 #include <fwMath/IntrasecTypes.hpp> 22 #include <boost/filesystem/convenience.hpp> 23 #include <boost/filesystem/path.hpp> 36 ::fwData::StructureTraitsDictionary::sptr structDico = ::fwData::StructureTraitsDictionary::New();
37 ::fwData::StructureTraits::sptr skin = ::fwData::StructureTraits::New();
38 std::string skinType =
"Skin";
39 skin->setType(skinType);
40 skin->setClass(::fwData::StructureTraits::ENVIRONMENT);
41 ::fwData::Color::sptr skinColor = ::fwData::Color::New(255.0f/255.0f, 179.0f/255.0f, 140.0f/255.0f, 1.0f);
42 skin->setColor(skinColor);
43 ::fwData::StructureTraits::CategoryContainer skinCat(1);
44 skinCat[0] = ::fwData::StructureTraits::BODY;
45 skin->setCategories(skinCat);
46 structDico->addStructure(skin);
48 ::fwData::StructureTraits::sptr liver = ::fwData::StructureTraits::New();
49 liver->setType(
"Liver");
50 liver->setClass(::fwData::StructureTraits::ORGAN);
51 liver->setColor(::fwData::Color::New(204.0f/255.0f, 51.0f/255.0f, 51.0f/255.0f, 1.0));
52 ::fwData::StructureTraits::CategoryContainer liverCat(1);
53 liverCat[0] = ::fwData::StructureTraits::ABDOMEN;
54 liver->setCategories(liverCat);
55 std::string nativeExp =
"inter(world(type(Skin)),not(class(Organ)))";
56 liver->setNativeExp(nativeExp);
57 structDico->addStructure(liver);
59 ::fwData::StructureTraits::sptr liverTumor = ::fwData::StructureTraits::New();
60 liverTumor->setType(
"Liver_Tumor");
61 liverTumor->setClass(::fwData::StructureTraits::LESION);
62 liverTumor->setColor(::fwData::Color::New(0.0f, 179.0f/255.0f, 0.0f, 1.0f));
63 ::fwData::StructureTraits::CategoryContainer liverTumorCat(1);
64 liverTumorCat[0] = ::fwData::StructureTraits::ABDOMEN;
65 liverTumor->setCategories(liverTumorCat);
66 liverTumor->setAttachmentType(
"Liver");
67 structDico->addStructure(liverTumor);
69 ::fwData::StructureTraits::sptr tumor = ::fwData::StructureTraits::New();
70 tumor->setType(
"Tumor");
71 tumor->setClass(::fwData::StructureTraits::LESION);
72 tumor->setColor(::fwData::Color::New(0.0f, 0.0f, 1.0f, 1.0f));
73 ::fwData::StructureTraits::CategoryContainer tumorCat(8);
74 tumorCat[0] = ::fwData::StructureTraits::BODY;
75 tumorCat[1] = ::fwData::StructureTraits::HEAD;
76 tumorCat[2] = ::fwData::StructureTraits::NECK;
77 tumorCat[3] = ::fwData::StructureTraits::THORAX;
78 tumorCat[4] = ::fwData::StructureTraits::ABDOMEN;
79 tumorCat[5] = ::fwData::StructureTraits::PELVIS;
80 tumorCat[6] = ::fwData::StructureTraits::ARM;
81 tumorCat[7] = ::fwData::StructureTraits::LEG;
82 tumor->setCategories(tumorCat);
84 ::fwData::StructureTraits::sptr colon = ::fwData::StructureTraits::New();
85 colon->setType(
"Colon");
86 colon->setClass(::fwData::StructureTraits::ORGAN);
87 colon->setColor(::fwData::Color::New(1.0f, 179.0f/255.0f, 128.0f/255.0f, 1.0f));
88 ::fwData::StructureTraits::CategoryContainer colonCat(1);
89 colonCat[0] = ::fwData::StructureTraits::ABDOMEN;
90 colon->setCategories(colonCat);
91 structDico->addStructure(colon);
93 ::fwData::StructureTraits::sptr caecum = ::fwData::StructureTraits::New();
94 caecum->setType(
"Caecum");
95 caecum->setClass(::fwData::StructureTraits::FUNCTIONAL);
96 caecum->setColor(::fwData::Color::New(1.0f, 179.0f/255.0f, 128.0f/255.0f, 1.0f));
97 ::fwData::StructureTraits::CategoryContainer caecumCat(1);
98 caecumCat[0] = ::fwData::StructureTraits::ABDOMEN;
99 caecum->setCategories(caecumCat);
100 caecum->setAttachmentType(
"Colon");
101 structDico->addStructure(caecum);
110 ::fwData::StructureTraits::sptr pStructureTraits = ::fwData::StructureTraits::New();
112 const std::string type =
"Liver";
113 const ::fwData::StructureTraits::StructureClass structClass = ::fwData::StructureTraits::ORGAN;
114 const ::fwData::StructureTraits::ROIExpression nativeExp =
"inter(world(type(Skin)),not(class(Organ)))";
115 const ::fwData::StructureTraits::ROIExpression nativeGeoExp =
"halfSpace(world(Left_lung),Z+,true)";
117 pStructureTraits->setType(type);
118 pStructureTraits->setClass(structClass);
119 pStructureTraits->setNativeExp(nativeExp);
120 pStructureTraits->setNativeGeometricExp(nativeGeoExp);
122 ::fwData::Color::sptr color = ::fwData::Color::New();
123 color->setRGBA(rand()%100 / 100.f, rand()%100 / 100.f, rand()%100 / 100.f, rand()%100 / 100.f);
124 pStructureTraits->setColor(color);
126 ::fwData::StructureTraits::CategoryContainer categories(2);
127 categories[0] = ::fwData::StructureTraits::ABDOMEN;
128 categories[1] = ::fwData::StructureTraits::BODY;
129 pStructureTraits->setCategories(categories);
131 return pStructureTraits;
138 ::fwData::Composite::sptr composite = ::fwData::Composite::New();
140 ::fwData::ROITraits::sptr roi = ::fwData::ROITraits::New();
141 std::stringstream ss;
142 ss <<
"ID_" << rand()%100;
143 roi->setIdentifier(ss.str());
145 roi->setEvaluatedExp(
"inter(skin),not(liver)");
147 roi->setStructureTraits(structure);
150 roi->setMaskOpNode(maskNode);
152 (*composite)[
"ROITraits"] = roi;
153 (*composite)[
"StructureTraits"] = structure;
154 (*composite)[
"MaskOpNode"] = maskNode;
163 ::fwData::Composite::sptr composite = ::fwData::Composite::New();
165 ::fwData::ReconstructionTraits::sptr rec = ::fwData::ReconstructionTraits::New();
167 std::stringstream ss;
168 ss <<
"ID_" << rand()%100;
169 rec->setIdentifier(ss.str());
172 rec->setStructureTraits(structure);
175 rec->setMaskOpNode(maskNode);
178 rec->setMeshOpNode(meshNode);
180 (*composite)[
"ReconstructionTraits"] = rec;
181 (*composite)[
"StructureTraits"] = structure;
182 (*composite)[
"MaskOpNode"] = maskNode;
183 (*composite)[
"MeshOpNode"] = meshNode;
192 ::fwData::Node::sptr node = ::fwData::Node::New();
194 unsigned int nbInputs = rand()%5;
195 unsigned int nbOutputs = rand()%5;
197 for (
unsigned int i = 0; i < nbInputs; ++i)
202 for (
unsigned int i = 0; i < nbOutputs; ++i)
214 ::fwData::Port::sptr port = ::fwData::Port::New();
216 std::stringstream ssId;
217 ssId <<
"ID_" << rand()%100;
218 port->setIdentifier(ssId.str());
220 std::stringstream ssType;
221 ssType <<
"Type_" << rand()%100;
222 port->setType(ssType.str());
231 ::fwData::Color::sptr col = ::fwData::Color::New();
232 col->setRGBA(rand()%100 / 100.f, rand()%100 / 100.f, rand()%100 / 100.f, rand()%100 / 100.f);
242 ::fwData::TransferFunction::sptr tf = ::fwData::TransferFunction::New();
245 rand()%100 / 100.f, rand()%100 / 100.f) );
246 tf->setInterpolationMode( ::fwData::TransferFunction::NEAREST );
247 tf->setIsClamped(
false );
249 tf->setName(
"TFColor" );
250 tf->setWindow(window );
252 for (
unsigned char nb = 0; nb < nbPoints; ++nb)
254 double value = rand()%100 - level;
255 tf->addTFColor( value,
257 rand()%100 / 100.f ));
260 ::fwData::String::sptr myString = ::fwData::String::New(
"fieldStringValue");
261 tf->setField(
"fieldStringKey", myString );
271 ::fwData::TransferFunction::sptr tf = ::fwData::TransferFunction::New();
274 tf->setInterpolationMode( ::fwData::TransferFunction::NEAREST );
275 tf->setIsClamped(
false );
276 tf->setLevel( 900.6 );
277 tf->setName(
"TFColor" );
278 tf->setWindow( -200.02 );
286 ::fwData::String::sptr myString = ::fwData::String::New(
"fieldStringValue");
287 tf->setField(
"fieldStringKey", myString );
298 ::fwData::Color::sptr ambient = ::fwData::Color::New();
299 ambient->setRGBA(0.5f, 0.5f, 0.5f, 0.5f);
301 ::fwData::Color::sptr diffuse = ::fwData::Color::New();
302 diffuse->setRGBA(0.8f, 0.2f, 0.5f, 0.4f);
304 ::fwData::Material::sptr material = ::fwData::Material::New();
316 const std::string IMAGEID1 =
"myImage1";
317 const std::string IMAGEID2 =
"myImage2";
318 const std::string FIELDID1 =
"myField1";
319 const std::string FIELDID2 =
"myField2";
320 ::fwData::Image::sptr image1 = ::fwData::Image::New();
321 ::fwData::Image::sptr image2 = ::fwData::Image::New();
322 ::fwData::Integer::sptr field1 = ::fwData::Integer::New(3);
323 ::fwData::Integer::sptr field2 = ::fwData::Integer::New(8);
326 ::fwData::ProcessObject::sptr po = ::fwData::ProcessObject::New();
327 po->setInputValue(IMAGEID1, image1);
328 po->setInputValue(FIELDID1, field1);
329 po->setInputValue(FIELDID2, field2);
330 po->setOutputValue(IMAGEID2, image2);
338 std::array< double, 3> coord = {
static_cast<double>(rand()%300),
339 static_cast<double>(rand()%300),
340 static_cast<double>(rand()%300)};
341 ::fwData::Point::sptr
point = ::fwData::Point::New();
342 point->setCoord(coord);
350 ::fwData::Plane::sptr plane = ::fwData::Plane::New();
352 plane->setIsIntersection(((rand()%1) ?
true :
false));
361 ::fwData::Resection::sptr resection = ::fwData::Resection::New();
363 resection->setName(
"Resection1");
364 resection->setIsSafePart(((rand()%1) ?
true :
false));
365 resection->setIsValid(((rand()%1) ?
true :
false));
366 resection->setIsVisible(((rand()%1) ?
true :
false));
367 ::fwData::Reconstruction::sptr recInput = ::fwData::Reconstruction::New();
370 ::fwData::Resection::ResectionInputs inputs;
371 inputs.push_back(recInput);
372 resection->setInputs(inputs);
374 ::fwData::Reconstruction::sptr recOutput = ::fwData::Reconstruction::New();
376 ::fwData::Resection::ResectionOutputs outputs;
377 outputs.push_back(recOutput);
378 resection->setOutputs(outputs);
380 ::fwData::PlaneList::PlaneListContainer planes;
383 ::fwData::PlaneList::sptr planeList = ::fwData::PlaneList::New();
384 planeList->setPlanes(planes);
393 ::fwData::ResectionDB::sptr resectionDB = ::fwData::ResectionDB::New();
static FWTEST_API::fwData::Material::sptr createMaterial()
Creates a Material with ambient and diffuse color.
static FWTEST_API::fwData::Point::sptr generatePoint()
Creates a Point with random coordinates.
static FWTEST_API::fwData::Composite::sptr createROITraits()
Return a composite containing the ROITraits and a reference on its StructureTraits and mask node (bec...
static FWTEST_API::fwData::Resection::sptr generateResection()
Creates a Resection with 2 planes, 1 input Reconstruction and 1 output Reconstruction.
static FWTEST_API::fwData::Plane::sptr generatePlane()
Creates a Plane with random points.
static FWTEST_API::fwData::Color::sptr randomizeColor()
Creates a color with random values.
static FWTEST_API::fwData::Composite::sptr createReconstructionTraits()
Return a composite containing the ReconstructionTraits and a reference on its StructureTraits and mas...
static FWTEST_API::fwData::Node::sptr createNode()
Creates a Node with random ports.
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.
static FWTEST_API::fwData::ProcessObject::sptr createProcessObject()
Creates a ProcessObject with 3 inputs and 1 output.
static FWTEST_API::fwData::ResectionDB::sptr generateResectionDB()
Creates a ResectionDB containing one Resection.
static FWTEST_API::fwData::StructureTraits::sptr createStructureTraits()
Creates a StructureTraits representing the liver.
Macro for deep and shallow copies.
static FWTEST_API void generateReconstruction(std::shared_ptr< ::fwData::Reconstruction > rec)
Generate a reconstruction.
static FWTEST_API::fwData::Port::sptr createPort()
Creates a Port with random identifier and type.
static FWTEST_API::fwData::TransferFunction::sptr createTFColor()
Creates a TransferFunction with few values.
static FWTEST_API::fwData::StructureTraitsDictionary::sptr createStructureTraitsDictionary()
Creates a StructureTraitsDictionary with many organs.