Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper-Free
Commits
346f2436
Commit
346f2436
authored
Nov 12, 2015
by
Christopher Tenter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor handle access to custom properties in poly lines
parent
caf3d5c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
43 deletions
+26
-43
ObjectTypes/PolyLine/PolyLineT.cc
ObjectTypes/PolyLine/PolyLineT.cc
+23
-40
ObjectTypes/PolyLine/PolyLineT.hh
ObjectTypes/PolyLine/PolyLineT.hh
+3
-3
No files found.
ObjectTypes/PolyLine/PolyLineT.cc
View file @
346f2436
...
...
@@ -2120,18 +2120,22 @@ split_into_one_per_component(MeshT &_mesh,
}
template
<
class
PointT
>
typename
PolyLineT
<
PointT
>::
CustomPropertyHandle
PolyLineT
<
PointT
>::
CustomProperty
::
handle
()
const
{
return
(
CustomPropertyHandle
)(
this
);
typename
PolyLineT
<
PointT
>::
CustomPropertyHandle
PolyLineT
<
PointT
>::
custom_prop_handle
(
const
CustomProperty
*
_prop
)
const
{
size_t
n
=
cprop_enum
.
size
();
for
(
int
i
=
0
;
i
<
n
;
++
i
)
if
(
cprop_enum
[
i
]
==
_prop
)
return
i
;
return
-
1
;
}
template
<
class
PointT
>
typename
PolyLineT
<
PointT
>::
CustomProperty
*
PolyLineT
<
PointT
>::
custom_prop
(
CustomPropertyHandle
_handle
)
{
return
reinterpret_cast
<
CustomProperty
*>
(
_handle
);
return
(
_handle
>=
0
?
cprop_enum
[
_handle
]
:
0
);
}
template
<
class
PointT
>
const
typename
PolyLineT
<
PointT
>::
CustomProperty
*
PolyLineT
<
PointT
>::
custom_prop
(
CustomPropertyHandle
_handle
)
const
{
return
reinterpret_cast
<
const
CustomProperty
*>
(
_handle
);
return
(
_handle
>=
0
?
cprop_enum
[
_handle
]
:
0
);
}
template
<
class
PointT
>
...
...
@@ -2166,20 +2170,17 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::
pcontainer
->
ref_count
=
1
;
}
return
pcontainer
->
handle
(
);
return
custom_prop_handle
(
pcontainer
);
}
template
<
class
PointT
>
void
PolyLineT
<
PointT
>::
release_custom_property
(
CustomPropertyHandle
_prop_handle
)
{
if
(
_prop_handle
)
{
CustomProperty
*
p
=
custom_prop
(
_prop_handle
)
;
CustomProperty
*
p
=
custom_prop
(
_prop_handle
);
if
(
--
p
->
ref_count
<=
0
)
p
->
prop_data
.
clear
();
}
if
(
p
&&
--
p
->
ref_count
<=
0
)
p
->
prop_data
.
clear
();
}
template
<
class
PointT
>
...
...
@@ -2192,7 +2193,7 @@ void PolyLineT<PointT>::
CustomProperty
*
p
=
entry
->
second
;
release_custom_property
(
p
->
handle
());
release_custom_property
(
custom_prop_
handle
(
p
));
}
}
...
...
@@ -2205,7 +2206,7 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::
if
(
it
==
custom_properties
.
end
())
return
0
;
return
it
->
second
->
handle
(
);
return
custom_prop_handle
(
it
->
second
);
}
template
<
class
PointT
>
...
...
@@ -2234,10 +2235,9 @@ void PolyLineT<PointT>::
return
;
}
if
(
_property_handle
)
{
CustomProperty
*
p
=
custom_prop
(
_property_handle
);
CustomProperty
*
p
=
custom_prop
(
_property_handle
);
if
(
p
)
{
unsigned
int
offset
=
p
->
prop_size
*
_i
;
// check out of range
...
...
@@ -2260,13 +2260,8 @@ void PolyLineT<PointT>::
unsigned
int
_i
,
const
void
*
_data
)
{
typename
CustomPropertyMap
::
iterator
entry
=
custom_properties
.
find
(
_name
);
if
(
entry
!=
custom_properties
.
end
())
{
CustomProperty
*
p
=
entry
->
second
;
set_custom_property
(
p
->
handle
(),
_i
,
_data
);
}
CustomPropertyHandle
h
=
get_custom_property_handle
(
_name
);
set_custom_property
(
h
,
_i
,
_data
);
}
template
<
class
PointT
>
...
...
@@ -2305,13 +2300,8 @@ void PolyLineT<PointT>::
unsigned
int
_i
,
void
*
_data
)
const
{
typename
CustomPropertyMap
::
const_iterator
entry
=
custom_properties
.
find
(
_name
);
if
(
entry
!=
custom_properties
.
end
())
{
const
CustomProperty
*
p
=
entry
->
second
;
get_custom_property
(
p
->
handle
(),
_i
,
_data
);
}
CustomPropertyHandle
h
=
get_custom_property_handle
(
_name
);
get_custom_property
(
h
,
_i
,
_data
);
}
...
...
@@ -2332,15 +2322,8 @@ template <class PointT>
bool
PolyLineT
<
PointT
>::
custom_property_available
(
const
std
::
string
&
_name
)
const
{
typename
CustomPropertyMap
::
const_iterator
entry
=
custom_properties
.
find
(
_name
);
if
(
entry
!=
custom_properties
.
end
())
{
const
CustomProperty
*
p
=
entry
->
second
;
return
custom_property_available
(
p
->
handle
());
}
return
false
;
CustomPropertyHandle
h
=
get_custom_property_handle
(
_name
);
return
custom_property_available
(
h
);
}
...
...
@@ -2410,7 +2393,7 @@ typename PolyLineT<PointT>::CustomPropertyHandle PolyLineT<PointT>::
enumerate_custom_property_handles
(
unsigned
int
_i
)
const
{
if
(
_i
<
get_num_custom_properties
())
return
cprop_enum
[
_i
]
->
h
andle
();
return
CustomPropertyH
andle
(
_i
);
else
return
0
;
}
...
...
ObjectTypes/PolyLine/PolyLineT.hh
View file @
346f2436
...
...
@@ -488,7 +488,7 @@ public:
}
*/
typedef
void
*
CustomPropertyHandle
;
typedef
int
CustomPropertyHandle
;
// request properties, returns handle of custom property
CustomPropertyHandle
request_custom_property
(
const
std
::
string
&
_name
,
unsigned
int
_prop_size
);
...
...
@@ -718,8 +718,6 @@ private:
char
*
buffer
()
{
return
prop_data
.
empty
()
?
0
:
&
prop_data
[
0
];}
const
char
*
buffer
()
const
{
return
prop_data
.
empty
()
?
0
:
&
prop_data
[
0
];}
CustomPropertyHandle
handle
()
const
;
};
typedef
std
::
map
<
std
::
string
,
CustomProperty
*
>
CustomPropertyMap
;
...
...
@@ -727,6 +725,8 @@ private:
CustomProperty
*
custom_prop
(
CustomPropertyHandle
_handle
);
const
CustomProperty
*
custom_prop
(
CustomPropertyHandle
_handle
)
const
;
CustomPropertyHandle
custom_prop_handle
(
const
CustomProperty
*
)
const
;
// map from property name to property data
CustomPropertyMap
custom_properties
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment