Skip to content

Commit 3247e3d

Browse files
committed
several small fixes
1 parent a70e5d1 commit 3247e3d

File tree

14 files changed

+111
-352
lines changed

14 files changed

+111
-352
lines changed

IfcPlusPlus/CMakeLists.txt

+33-40
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
CMAKE_MINIMUM_REQUIRED (VERSION 2.8...3.7.2)
2-
3-
IF(WIN32)
4-
# for vs2017
5-
SET(VC_LIBS Bcrypt.lib)
6-
ENDIF(WIN32)
7-
8-
IF(NOT WIN32)
9-
IF(NOT CMAKE_BUILD_TYPE)
10-
SET(CMAKE_BUILD_TYPE "Release")
11-
ENDIF()
12-
13-
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
14-
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
15-
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
16-
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
17-
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
18-
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
19-
ENDIF(NOT WIN32)
20-
21-
FILE (GLOB ifc4_source "src/ifcpp/IFC4/lib/*.cpp")
1+
cmake_minimum_required (VERSION 2.8...3.7.2)
2+
3+
if(WIN32)
4+
# for vs2017
5+
set(VC_LIBS Bcrypt.lib)
6+
else(WIN32)
7+
if(NOT CMAKE_BUILD_TYPE)
8+
set(CMAKE_BUILD_TYPE "Release")
9+
endif()
10+
11+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
12+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
13+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
14+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
15+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
16+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
17+
endif(WIN32)
18+
19+
file (GLOB ifc4_source "src/ifcpp/IFC4/lib/*.cpp")
2220

2321
if(UNIX)
2422
# do not add src/external/XUnzip.cpp on unix plattforms
@@ -59,51 +57,46 @@ endif(UNIX)
5957

6058
if (MSVC)
6159
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj ")
62-
ENDIF()
60+
endif()
6361

64-
IF(BUILD_STATIC_LIBRARY)
65-
ADD_DEFINITIONS(-DIFCQUERY_STATIC_LIB)
66-
ADD_LIBRARY(IfcPlusPlus STATIC ${IFCPP_SOURCE_FILES})
67-
ELSE(BUILD_STATIC_LIBRARY)
68-
ADD_DEFINITIONS(-DIFCQUERY_AS_DYNAMIC_LIBRARY)
69-
ADD_DEFINITIONS(-DIFCQUERY_LIB)
70-
ADD_LIBRARY(IfcPlusPlus SHARED ${IFCPP_SOURCE_FILES})
71-
ENDIF(BUILD_STATIC_LIBRARY)
62+
add_definitions(-DIFCQUERY_AS_DYNAMIC_LIBRARY)
63+
add_definitions(-DIFCQUERY_LIB)
64+
add_library(IfcPlusPlus SHARED ${IFCPP_SOURCE_FILES})
7265

7366
link_directories( ${CMAKE_BINARY_DIR}/IfcPlusPlus/${CMAKE_BUILD_TYPE} )
7467
link_directories( ${CMAKE_BINARY_DIR}/external/Carve/${CMAKE_BUILD_TYPE} )
75-
TARGET_LINK_LIBRARIES(IfcPlusPlus
68+
target_link_libraries(IfcPlusPlus
7669
PUBLIC
7770
carve
7871
${VC_LIBS}
7972
)
8073

81-
TARGET_INCLUDE_DIRECTORIES(IfcPlusPlus
74+
target_include_directories(IfcPlusPlus
8275
PUBLIC
8376
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
8477
"$<INSTALL_INTERFACE:include>")
8578

8679
set_target_properties(IfcPlusPlus PROPERTIES DEBUG_POSTFIX "d")
8780

88-
IF(WIN32)
81+
if(WIN32)
8982
set_target_properties(IfcPlusPlus PROPERTIES LINK_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
90-
ENDIF()
83+
endif()
9184

92-
INSTALL(
85+
install(
9386
DIRECTORY src/ifcpp
9487
DESTINATION include
9588
FILES_MATCHING PATTERN "*.h"
9689
)
97-
INSTALL(
90+
install(
9891
TARGETS IfcPlusPlus
9992
EXPORT IfcPlusPlus
10093
RUNTIME DESTINATION bin
101-
LIBRARY DESTINATION lib
102-
ARCHIVE DESTINATION lib
94+
LIBRARY DESTINATION bin
95+
ARCHIVE DESTINATION bin
10396
)
10497

105-
SET(target_output_filename IfcPlusPlus-targets.cmake)
106-
SET(target_output "${CMAKE_BINARY_DIR}/cmake/${target_output_filename}")
98+
set(target_output_filename IfcPlusPlus-targets.cmake)
99+
set(target_output "${CMAKE_BINARY_DIR}/cmake/${target_output_filename}")
107100

108101
export(
109102
EXPORT IfcPlusPlus

IfcPlusPlus/src/ifcpp/geometry/Carve/CSG_Adapter.h

+5-193
Original file line numberDiff line numberDiff line change
@@ -78,141 +78,7 @@ namespace CSG_Adapter
7878
vertex.v.z = round( vertex.v.z*1000000.0 ) * 0.000001;
7979
}
8080
}
81-
inline void mergeAlignedEdges( shared_ptr<meshset_t >& meshset, carve::mesh::MeshSimplifier& simplifier )
82-
{
83-
if( !meshset )
84-
{
85-
return;
86-
}
87-
88-
std::map<face_t*, std::vector<carve::mesh::Edge<3>*> > map_omit_face_edges;
89-
for( size_t i_mesh = 0; i_mesh < meshset->meshes.size(); ++i_mesh )
90-
{
91-
carve::mesh::Mesh<3>* mesh = meshset->meshes[i_mesh];
92-
93-
const std::vector<carve::mesh::Edge<3>*>& vec_closed_edges = mesh->closed_edges;
94-
bool mesh_dirty = false;
95-
for( size_t closed_edge_i = 0; closed_edge_i < vec_closed_edges.size(); ++closed_edge_i )
96-
{
97-
carve::mesh::Edge<3>* edge_i = vec_closed_edges[closed_edge_i];
98-
carve::mesh::Edge<3>* edge_next = edge_i->next;
99-
if( !edge_next )
100-
{
101-
continue;
102-
}
103-
104-
if( !edge_i )
105-
{
106-
#ifdef _DEBUG
107-
std::cout << __FUNC__ << ": !edge_i" << std::endl;
108-
#endif
109-
continue;
110-
}
111-
112-
if( !edge_next )
113-
{
114-
#ifdef _DEBUG
115-
std::cout << __FUNC__ << ": !edge_next" << std::endl;
116-
#endif
117-
continue;
118-
}
119-
120-
if( !edge_next->rev )
121-
{
122-
#ifdef _DEBUG
123-
std::cout << __FUNC__ << ": !edge_j->rev" << std::endl;
124-
#endif
125-
continue;
126-
}
127-
128-
if( edge_next->rev->next == edge_i->rev )
129-
{
130-
// ----------->(v3)---> --->o--->
131-
// |^ |^
132-
// edge_next->rev||edge_next(remove) ||
133-
// v| ||
134-
// (v2) ||
135-
// |^ ||
136-
// (remove)||edge_i ||edge_i
137-
// v| v|
138-
// <----------(v1)<--- <---o<---
139-
140-
const carve::mesh::Vertex<3>* v1 = edge_i->v1();
141-
const carve::mesh::Vertex<3>* v2 = edge_i->v2();
142-
const carve::mesh::Vertex<3>* v3 = edge_next->v2();
143-
144-
const vec3& v1vec = v1->v;
145-
const vec3& v2vec = v2->v;
146-
const vec3& v3vec = v3->v;
147-
vec3 sement12 = v2vec - v1vec;
148-
vec3 sement23 = v3vec - v2vec;
149-
#ifdef _DEBUG
150-
double sement12_length2 = sement12.length2();
151-
double sement23_length2 = sement23.length2();
152-
if( std::abs( edge_i->length2() - sement12_length2 ) > 0.00001 )
153-
{
154-
std::cout << __FUNC__ << ": abs( edge_i->length2() - sement12_length2 ) > 0.00001" << std::endl;
155-
}
156-
157-
if( std::abs( edge_next->length2() - sement23_length2 ) > 0.00001 )
158-
{
159-
std::cout << __FUNC__ << ": abs( edge_next->length2() - sement23_length2 ) > 0.00001" << std::endl;
160-
}
161-
#endif
162-
163-
// check angle between edges
164-
sement12.normalize();
165-
sement23.normalize();
166-
double dot_angle = dot( sement12, sement23 );
167-
if( std::abs( std::abs( dot_angle ) - 1.0 ) < 0.001 )
168-
{
169-
// edges are in line
170-
if( v1 == v3 )
171-
{
172-
#ifdef _DEBUG
173-
std::cout << __FUNC__ << ": edge loop with only 2 edges" << std::endl;
174-
#endif
175-
//edge_i->rev == edge_next
176-
edge_i->removeEdge(); //also removes edge_i->rev
177-
}
178-
else
179-
{
180-
// this links previous and next edges and deletes edge_j and reverse of edge_i:
181-
edge_i->rev->removeHalfEdge();
182-
edge_i->rev = edge_next->rev;
183-
184-
edge_next->rev->rev = edge_i;
185-
edge_next->removeHalfEdge();
186-
mesh_dirty = true;
187-
}
188-
189-
// the vertex is kept in the vertex storage, no need to delete here
190-
}
191-
else
192-
{
193-
// edges are not in line, so faces should be in a plane
194-
#ifdef _DEBUG
195-
const vec3& normal_face_i = edge_i->face->plane.N;
196-
const vec3& normal_face_i_rev = edge_i->rev->face->plane.N;
197-
198-
199-
double dot_face_angle = dot( normal_face_i, normal_face_i_rev );
200-
if( std::abs( dot_face_angle - 1.0 ) > 0.001 )
201-
{
202-
std::cout << __FUNC__ << ": abs( dot_face_angle - 1.0 ) > 0.001" << std::endl;
203-
}
204-
#endif
205-
}
206-
}
207-
}
208-
209-
if (mesh_dirty)
210-
{
211-
//clears closed_edges and rebuilds it from faces
212-
mesh->cacheEdges();
213-
}
214-
}
215-
}
81+
21682
inline bool checkMeshSetNonNegativeAndClosed( const shared_ptr<meshset_t> mesh_set )
21783
{
21884
bool meshes_closed = true;
@@ -577,11 +443,6 @@ namespace CSG_Adapter
577443
++i_vert;
578444
} while( edge != face->edge );
579445

580-
//std::vector<carve::mesh::Vertex<3>* > verts;
581-
//face->getVertices( verts );
582-
583-
// TODO: merge coplanar faces and re-triangulate
584-
585446
for( size_t i = 0; i != triangulated.size(); ++i )
586447
{
587448
const carve::triangulate::tri_idx& triangle = triangulated[i];
@@ -626,32 +487,9 @@ namespace CSG_Adapter
626487
meshset.reset();
627488
meshset = shared_ptr<meshset_t >( poly_cache.m_poly_data->createMesh( carve::input::opts() ) );
628489
}
490+
629491
inline void simplifyMesh( shared_ptr<meshset_t >& meshset, bool triangulate, StatusCallback* report_callback, BuildingEntity* entity )
630492
{
631-
carve::mesh::MeshSimplifier simplifier;
632-
//double min_colinearity = m_geom_settings->m_min_colinearity;
633-
//double min_delta_v = m_geom_settings->m_min_delta_v;
634-
//double min_normal_angle = m_geom_settings->m_min_normal_angle;
635-
//double min_length = 0.0001;//m_geom_settings->m_min_length;
636-
637-
//try
638-
//{
639-
// simplifier.removeFins(meshset.get());
640-
// //simplifier.cleanFaceEdges( meshset.get() );
641-
// //simplifier.removeRemnantFaces( meshset.get() );
642-
// //simplifier.mergeCoplanarFaces( meshset.get(), 0.0 );
643-
// //simplifier.eliminateShortEdges( meshset.get(), min_length );
644-
// //simplifier.removeFins(meshset.get());
645-
// simplifier.simplify( meshset.get(), min_colinearity, min_delta_v, min_normal_angle, min_length );
646-
// simplifier.removeFins(meshset.get());
647-
// //simplifier.removeLowVolumeManifolds(meshset, 0.01);
648-
// simplifier.improveMesh( meshset.get(), m_geom_settings->m_min_colinearity, m_geom_settings->m_min_delta_v, m_geom_settings->m_min_normal_angle );
649-
//}
650-
//catch(...)
651-
//{
652-
// std::cout << "simplifier.eliminateShortEdges failed." << std::endl;
653-
//}
654-
655493
if( !meshset )
656494
{
657495
return;
@@ -671,48 +509,22 @@ namespace CSG_Adapter
671509
#endif
672510
return;
673511
}
512+
674513
shared_ptr<meshset_t > meshset_copy( meshset->clone() );
514+
carve::mesh::MeshSimplifier simplifier;
675515
simplifier.removeLowVolumeManifolds( meshset.get(), 0.000000001 );
676516

677517
if( meshset->meshes.size() < 1 )
678518
{
679519
return;
680520
}
681521

682-
//size_t num_faces = getNumFaces( meshset.get() );
683-
// merge faces if their normals have a difference less than 10^-5 rad
684-
/*size_t modifications_coplanar = simplifier.mergeCoplanarFaces( meshset.get(), 0.00001 );
685-
if( modifications_coplanar > 0 )
686-
{
687-
int num_faces_post_merge = getNumFaces( meshset.get() );
688-
if( num_faces_post_merge + modifications_coplanar != num_faces )
689-
{
690-
#ifdef _DEBUG
691-
std::cout << "num_faces_post_merge + modifications_coplanar != num_faces" << std::endl;
692-
#endif
693-
}
694-
}*/
695-
696522
bool faces_ok = checkFaceIntegrity( meshset );
697523
if( !faces_ok )
698524
{
699525
meshset = meshset_copy;
700526
#ifdef _DEBUG
701-
std::cout << "Error in simplifier.mergeCoplanarFaces" << std::endl;
702-
#endif
703-
return;
704-
}
705-
706-
meshset_copy = shared_ptr<meshset_t >( meshset->clone() );
707-
//mergeAlignedEdges( meshset, simplifier );
708-
meshset->collectVertices(); //removes unreferenced Vertices
709-
710-
faces_ok = checkFaceIntegrity( meshset );
711-
if( !faces_ok )
712-
{
713-
meshset = meshset_copy;
714-
#ifdef _DEBUG
715-
std::cout << "Error in mergeAlignedEdges" << std::endl;
527+
std::cout << "Error in checkFaceIntegrity" << std::endl;
716528
#endif
717529
return;
718530
}

IfcPlusPlus/src/ifcpp/geometry/Carve/CurveConverter.h

+11-10
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ class CurveConverter : public StatusCallback
121121
void convertIfcCurve( const shared_ptr<IfcCurve>& ifc_curve, std::vector<vec3>& target_vec, std::vector<vec3>& segment_start_points,
122122
std::vector<shared_ptr<IfcTrimmingSelect> >& trim1_vec, std::vector<shared_ptr<IfcTrimmingSelect> >& trim2_vec, bool sense_agreement ) const
123123
{
124+
if (!ifc_curve)
125+
{
126+
return;
127+
}
124128
double length_factor = m_point_converter->getUnitConverter()->getLengthInMeterFactor();
125129

126130
// ENTITY IfcCurve ABSTRACT SUPERTYPE OF (ONEOF(IfcBoundedCurve, IfcConic, IfcLine, IfcOffsetCurve2D, IfcOffsetCurve3D, IfcPCurve))
@@ -169,17 +173,14 @@ class CurveConverter : public StatusCallback
169173
shared_ptr<IfcTrimmedCurve> trimmed_curve = dynamic_pointer_cast<IfcTrimmedCurve>( bounded_curve );
170174
if( trimmed_curve )
171175
{
172-
shared_ptr<IfcCurve> basis_curve = trimmed_curve->m_BasisCurve;
173-
if( basis_curve )
174-
{
175-
std::vector<vec3> basis_curve_points;
176-
std::vector<shared_ptr<IfcTrimmingSelect> >& curve_trim1_vec = trimmed_curve->m_Trim1;
177-
std::vector<shared_ptr<IfcTrimmingSelect> >& curve_trim2_vec = trimmed_curve->m_Trim2;
178-
bool trimmed_sense_agreement = trimmed_curve->m_SenseAgreement ? trimmed_curve->m_SenseAgreement->m_value : true;
176+
std::vector<vec3> basis_curve_points;
177+
std::vector<shared_ptr<IfcTrimmingSelect> >& curve_trim1_vec = trimmed_curve->m_Trim1;
178+
std::vector<shared_ptr<IfcTrimmingSelect> >& curve_trim2_vec = trimmed_curve->m_Trim2;
179+
bool trimmed_sense_agreement = trimmed_curve->m_SenseAgreement ? trimmed_curve->m_SenseAgreement->m_value : true;
179180

180-
convertIfcCurve( basis_curve, basis_curve_points, segment_start_points, curve_trim1_vec, curve_trim2_vec, trimmed_sense_agreement );
181-
GeomUtils::appendPointsToCurve( basis_curve_points, target_vec );
182-
}
181+
shared_ptr<IfcCurve> basis_curve = trimmed_curve->m_BasisCurve;
182+
convertIfcCurve( basis_curve, basis_curve_points, segment_start_points, curve_trim1_vec, curve_trim2_vec, trimmed_sense_agreement );
183+
GeomUtils::appendPointsToCurve( basis_curve_points, target_vec );
183184
return;
184185
}
185186

IfcPlusPlus/src/ifcpp/geometry/Carve/GeomUtils.h

+1
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ namespace GeomUtils
684684
}
685685
previous_x = current_point.x;
686686
previous_y = current_point.y;
687+
previous_z = current_point.z;
687688
++it_loop;
688689
}
689690
}

0 commit comments

Comments
 (0)