- Timestamp:
- 11/22/17 02:50:49 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f1/conv_f1.cpp
r672 r716 9 9 #include <frams/util/multimap.h> 10 10 #include <ctype.h> 11 #include <assert.h> 11 12 12 13 //#define v1f1COMPATIBLE //as in ancient Framsticks 1.x … … 18 19 { 19 20 public: 20 Builder(const char*g, int mapping = 0) :invalid(0), genbegin(g), usemapping(mapping), first_part_mapping(NULL), model_energy(0), model_energy_count(0) {}21 ~Builder() { SAFEDELETE(first_part_mapping); }21 Builder(const char*g, int mapping = 0) :invalid(0), genbegin(g), usemapping(mapping), first_part_mapping(NULL), own_first_part_mapping(true), model_energy(0), model_energy_count(0) {} 22 ~Builder() { if (own_first_part_mapping) SAFEDELETE(first_part_mapping); } 22 23 char tmp[222]; 23 24 bool invalid; … … 38 39 MultiRange range; 39 40 MultiRange *first_part_mapping; 41 bool own_first_part_mapping; 40 42 double lastjoint_muscle_power; 41 43 double model_energy; … … 125 127 { //special case: mapping the part which is not yet created 126 128 if (first_part_mapping) first_part_mapping->add(*r); 127 else first_part_mapping = new MultiRange(*r);129 else { first_part_mapping = new MultiRange(*r); own_first_part_mapping = true; } 128 130 } 129 131 else … … 199 201 freshpart = 1; 200 202 if (first_part_mapping) 203 { 204 //mapping was defined before creating this initial Part -> put it into the Part 205 assert(own_first_part_mapping); 201 206 model.getPart(part1)->setMapping(*first_part_mapping); 207 delete first_part_mapping; 208 //first_part_mapping can be still used later but from now on it references the internal Part mapping 209 first_part_mapping = model.getPart(part1)->getMapping(); 210 own_first_part_mapping = false; 211 } 202 212 } 203 213 } … … 243 253 c.muscle_bend_range = 1.0 / count; 244 254 for (i = 0; i < count; i++) 245 grow(part1, (char*)ga(i), k + Pt3D(0, 0, -M_PI + (i + 1)*(2 *M_PI / (count + 1))), c);255 grow(part1, (char*)ga(i), k + Pt3D(0, 0, -M_PI + (i + 1)*(2 * M_PI / (count + 1))), c); 246 256 return; 247 257 }
Note: See TracChangeset
for help on using the changeset viewer.