Skip to content

Commit ef9a2d3

Browse files
committed
Merge branch 'next' into feat/generic_aabb_search
2 parents b675c54 + 9ff2eb5 commit ef9a2d3

File tree

7 files changed

+417
-2
lines changed

7 files changed

+417
-2
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2019 - 2024 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#include <geode/model/common.h>
27+
#include <geode/model/representation/core/mapping.h>
28+
29+
namespace geode
30+
{
31+
namespace detail
32+
{
33+
ModelGenericMapping merge_mappings(
34+
const ModelGenericMapping& mappings1,
35+
const ModelCopyMapping& mappings2 );
36+
37+
ModelGenericMapping merge_mappings(
38+
const ModelGenericMapping& mappings1,
39+
const ModelGenericMapping& mappings2 );
40+
41+
ModelGenericMapping copy_to_generic_mappings(
42+
const ModelCopyMapping& mappings2 );
43+
44+
ModelMappings merge_mappings(
45+
const ModelMappings& mappings1, const ModelMappings& mappings2 );
46+
} // namespace detail
47+
} // namespace geode

include/geode/model/representation/builder/brep_builder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@
5151

5252
namespace geode
5353
{
54+
FORWARD_DECLARATION_DIMENSION_CLASS( Point );
5455
FORWARD_DECLARATION_DIMENSION_CLASS( EdgedCurve );
5556
FORWARD_DECLARATION_DIMENSION_CLASS( PointSet );
5657
FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh );
5758
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
59+
ALIAS_3D( Point );
5860
ALIAS_3D( Block );
5961
ALIAS_3D( Corner );
6062
ALIAS_3D( EdgedCurve );
@@ -236,6 +238,8 @@ namespace geode
236238
void add_block_in_block_collection(
237239
const Block3D& surface, const BlockCollection3D& collection );
238240

241+
void set_point( index_t unique_vertex, const Point3D& point );
242+
239243
private:
240244
BRep& brep_;
241245
};

include/geode/model/representation/builder/section_builder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@
4747

4848
namespace geode
4949
{
50+
FORWARD_DECLARATION_DIMENSION_CLASS( Point );
5051
FORWARD_DECLARATION_DIMENSION_CLASS( EdgedCurve );
5152
FORWARD_DECLARATION_DIMENSION_CLASS( PointSet );
5253
FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh );
54+
ALIAS_2D( Point );
5355
ALIAS_2D( Corner );
5456
ALIAS_2D( EdgedCurve );
5557
ALIAS_2D( PointSet );
@@ -192,6 +194,8 @@ namespace geode
192194
void add_surface_in_surface_collection(
193195
const Surface2D& surface, const SurfaceCollection2D& collection );
194196

197+
void set_point( index_t unique_vertex, const Point2D& point );
198+
195199
private:
196200
Section& section_;
197201
};

include/geode/model/representation/core/mapping.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace geode
8383
}
8484

8585
const absl::flat_hash_map< ComponentType, Mapping >&
86-
components_mappings()
86+
components_mappings() const
8787
{
8888
return mappings;
8989
}
@@ -137,4 +137,18 @@ namespace geode
137137
{
138138
MeshVertexMapping blocks;
139139
};
140+
141+
struct ModelMappings
142+
{
143+
ModelGenericMapping component_mapping;
144+
ModelMeshesElementMapping mesh_element_mapping;
145+
ModelMeshesVertexMapping mesh_vertices_mapping;
146+
};
147+
148+
struct BRepMappings
149+
{
150+
ModelGenericMapping component_mapping;
151+
BRepMeshesElementMapping mesh_element_mapping;
152+
BRepMeshesVertexMapping mesh_vertices_mapping;
153+
};
140154
} // namespace geode
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
/*
2+
* Copyright (c) 2019 - 2024 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#include <geode/model/helpers/detail/mappings_merger.h>
25+
26+
#include <geode/model/mixin/core/block.h>
27+
#include <geode/model/mixin/core/block_collection.h>
28+
#include <geode/model/mixin/core/corner.h>
29+
#include <geode/model/mixin/core/corner_collection.h>
30+
#include <geode/model/mixin/core/line.h>
31+
#include <geode/model/mixin/core/line_collection.h>
32+
#include <geode/model/mixin/core/model_boundary.h>
33+
#include <geode/model/mixin/core/surface.h>
34+
#include <geode/model/mixin/core/surface_collection.h>
35+
36+
namespace
37+
{
38+
class GenericandCopyMappingsMerger
39+
{
40+
public:
41+
GenericandCopyMappingsMerger(
42+
const geode::ModelGenericMapping& mappings1,
43+
const geode::ModelCopyMapping& mappings2 )
44+
: mappings1_( mappings1 ), mappings2_( mappings2 )
45+
{
46+
}
47+
48+
geode::ModelGenericMapping merge()
49+
{
50+
geode::ModelGenericMapping result;
51+
for( const auto& component_mapping :
52+
mappings1_.components_mappings() )
53+
{
54+
if( mappings2_.has_mapping_type( component_mapping.first ) )
55+
{
56+
result.emplace( component_mapping.first,
57+
merge_mappings( component_mapping.second,
58+
mappings2_.at( component_mapping.first ) ) );
59+
}
60+
}
61+
return result;
62+
}
63+
64+
private:
65+
geode::ModelGenericMapping::Mapping merge_mappings(
66+
const geode::ModelGenericMapping::Mapping& mappings1,
67+
const geode::ModelCopyMapping::Mapping& mappings2 )
68+
{
69+
geode::ModelGenericMapping::Mapping result;
70+
for( const auto& in2between : mappings1.in2out_map() )
71+
{
72+
for( const auto& between_id : in2between.second )
73+
{
74+
if( !mappings2.has_mapping_input( between_id ) )
75+
{
76+
continue;
77+
}
78+
result.map(
79+
in2between.first, mappings2.in2out( between_id ) );
80+
}
81+
}
82+
return result;
83+
}
84+
85+
private:
86+
const geode::ModelGenericMapping& mappings1_;
87+
const geode::ModelCopyMapping& mappings2_;
88+
};
89+
90+
class GenericMappingsMerger
91+
{
92+
public:
93+
GenericMappingsMerger( const geode::ModelGenericMapping& mappings1,
94+
const geode::ModelGenericMapping& mappings2 )
95+
: mappings1_( mappings1 ), mappings2_( mappings2 )
96+
{
97+
}
98+
99+
geode::ModelGenericMapping merge()
100+
{
101+
geode::ModelGenericMapping result;
102+
for( const auto& component_mapping :
103+
mappings1_.components_mappings() )
104+
{
105+
if( mappings2_.has_mapping_type( component_mapping.first ) )
106+
{
107+
result.emplace( component_mapping.first,
108+
merge_mappings( component_mapping.second,
109+
mappings2_.at( component_mapping.first ) ) );
110+
}
111+
}
112+
return result;
113+
}
114+
115+
private:
116+
geode::ModelGenericMapping::Mapping merge_mappings(
117+
const geode::ModelGenericMapping::Mapping& mappings1,
118+
const geode::ModelGenericMapping::Mapping& mappings2 )
119+
{
120+
geode::ModelGenericMapping::Mapping result;
121+
for( const auto& in2between : mappings1.in2out_map() )
122+
{
123+
for( const auto& between_id : in2between.second )
124+
{
125+
if( !mappings2.has_mapping_input( between_id ) )
126+
{
127+
continue;
128+
}
129+
for( const auto& out_id : mappings2.in2out( between_id ) )
130+
{
131+
result.map( in2between.first, out_id );
132+
}
133+
}
134+
}
135+
return result;
136+
}
137+
138+
private:
139+
const geode::ModelGenericMapping& mappings1_;
140+
const geode::ModelGenericMapping& mappings2_;
141+
};
142+
143+
class CopyToGenericMappings
144+
{
145+
public:
146+
CopyToGenericMappings( const geode::ModelCopyMapping& mappings )
147+
: mappings_( mappings )
148+
{
149+
}
150+
151+
geode::ModelGenericMapping transfer()
152+
{
153+
for( const auto& component_mapping :
154+
mappings_.components_mappings() )
155+
{
156+
result_.emplace( component_mapping.first,
157+
transfer_mappings( component_mapping.second ) );
158+
}
159+
return std::move( result_ );
160+
}
161+
162+
private:
163+
geode::ModelGenericMapping::Mapping transfer_mappings(
164+
const geode::ModelCopyMapping::Mapping& copy_mappings )
165+
{
166+
geode::ModelGenericMapping::Mapping result;
167+
for( const auto& in2out : copy_mappings.in2out_map() )
168+
{
169+
result.map( in2out.first, in2out.second );
170+
}
171+
return result;
172+
}
173+
174+
private:
175+
const geode::ModelCopyMapping& mappings_;
176+
geode::ModelGenericMapping result_;
177+
};
178+
179+
geode::MeshElementMapping merge_element_mappings(
180+
const geode::MeshElementMapping& mappings1,
181+
const geode::MeshElementMapping& mappings2 )
182+
{
183+
geode::MeshElementMapping result;
184+
for( const auto& first_mapping : mappings1.in2out_map() )
185+
{
186+
for( const auto& intermediate_element : first_mapping.second )
187+
{
188+
if( !mappings2.has_mapping_input( intermediate_element ) )
189+
{
190+
continue;
191+
}
192+
for( const auto& out_element :
193+
mappings2.in2out( intermediate_element ) )
194+
{
195+
result.map( first_mapping.first, out_element );
196+
}
197+
}
198+
}
199+
return result;
200+
}
201+
202+
geode::MeshVertexMapping merge_vertex_mappings(
203+
const geode::MeshVertexMapping& mappings1,
204+
const geode::MeshVertexMapping& mappings2 )
205+
{
206+
geode::MeshVertexMapping result;
207+
for( const auto& first_mapping : mappings1.in2out_map() )
208+
{
209+
for( const auto& intermediate_vertex : first_mapping.second )
210+
{
211+
if( !mappings2.has_mapping_input( intermediate_vertex ) )
212+
{
213+
continue;
214+
}
215+
for( const auto& out_vertex :
216+
mappings2.in2out( intermediate_vertex ) )
217+
{
218+
result.map( first_mapping.first, out_vertex );
219+
}
220+
}
221+
}
222+
return result;
223+
}
224+
} // namespace
225+
226+
namespace geode
227+
{
228+
namespace detail
229+
{
230+
ModelGenericMapping merge_mappings(
231+
const ModelGenericMapping& mappings1,
232+
const ModelCopyMapping& mappings2 )
233+
{
234+
GenericandCopyMappingsMerger merger{ mappings1, mappings2 };
235+
return merger.merge();
236+
}
237+
238+
ModelGenericMapping merge_mappings(
239+
const ModelGenericMapping& mappings1,
240+
const ModelGenericMapping& mappings2 )
241+
{
242+
GenericMappingsMerger merger{ mappings1, mappings2 };
243+
return merger.merge();
244+
}
245+
246+
ModelGenericMapping copy_to_generic_mappings(
247+
const ModelCopyMapping& mappings )
248+
{
249+
CopyToGenericMappings transferer{ mappings };
250+
return transferer.transfer();
251+
}
252+
253+
ModelMappings merge_mappings(
254+
const ModelMappings& mappings1, const ModelMappings& mappings2 )
255+
{
256+
ModelMappings result;
257+
result.component_mapping = merge_mappings(
258+
mappings1.component_mapping, mappings2.component_mapping );
259+
result.mesh_element_mapping.corners =
260+
merge_element_mappings( mappings1.mesh_element_mapping.corners,
261+
mappings2.mesh_element_mapping.corners );
262+
result.mesh_element_mapping.lines =
263+
merge_element_mappings( mappings1.mesh_element_mapping.lines,
264+
mappings2.mesh_element_mapping.lines );
265+
result.mesh_element_mapping.surfaces =
266+
merge_element_mappings( mappings1.mesh_element_mapping.surfaces,
267+
mappings2.mesh_element_mapping.surfaces );
268+
result.mesh_vertices_mapping.corners =
269+
merge_vertex_mappings( mappings1.mesh_vertices_mapping.corners,
270+
mappings2.mesh_vertices_mapping.corners );
271+
result.mesh_vertices_mapping.lines =
272+
merge_vertex_mappings( mappings1.mesh_vertices_mapping.lines,
273+
mappings2.mesh_vertices_mapping.lines );
274+
result.mesh_vertices_mapping.surfaces =
275+
merge_vertex_mappings( mappings1.mesh_vertices_mapping.surfaces,
276+
mappings2.mesh_vertices_mapping.surfaces );
277+
}
278+
} // namespace detail
279+
} // namespace geode

0 commit comments

Comments
 (0)